| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| nostep 
 
 
 Joined: 04 Mar 2009
 Posts: 16
 
 
 
			    
 
 | 
			
				| PWM on dspic30F |  
				|  Posted: Mon Mar 16, 2009 7:02 am |   |  
				| 
 |  
				| I have PWM working on a dsPic30F6012A.  Is there a way to not get the first startup pulse?  At each bootup there is a short full-on pulse until the PWM gets into sink and starts back at 0 PWM. 
 Here's some pseudo code.
 
 10MHZ crystal on XLTx4 (40,000,000 clock)
 
 main()
 {
 . . .
 
 setup_timer3(TMR_INTERNAL|TMR_DIV_BY_64,780);  // 200HZ PWM
 setup_pwm_duty(6,0);                           // using OC6 = pin_D5
 setup_compare(6,COMPARE_PWM|COMPARE_TIMER3);  // using OC6 = Pin_RD5
 
 . . .
 
 while(1);
 }
 
 With the above I get a 200us pulse at bootup, then it goes to zero like it's supposed to while I wait to use the channel.  I've tried messing with the timer to see if I could trick it into staying off, but nothing seems to work.
 
 Thanks.
 |  | 
	
		|  | 
	
		| Ttelmah Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				|  |  
				|  Posted: Mon Mar 16, 2009 8:14 am |   |  
				| 
 |  
				| Try not enabling the timer, till after you have setup the PWM. This is what the MicroChip data sheet suggests. 
 Best Wishes
 |  | 
	
		|  | 
	
		| nostep 
 
 
 Joined: 04 Mar 2009
 Posts: 16
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Mar 16, 2009 11:55 am |   |  
				| 
 |  
				| I think I get the pulse when I do this line: 
 setup_compare(6,COMPARE_PWM|COMPARE_TIMER3); // using OC6 = Pin_RD5
 
 I don't know what else to try.
 |  | 
	
		|  | 
	
		|  |