CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PWM pin high after powerup

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
koenbielen



Joined: 23 Apr 2009
Posts: 42

View user's profile Send private message

PWM pin high after powerup
PostPosted: Tue May 05, 2009 9:50 am     Reply with quote

Hi,

I am using the 18F4525 and use the PWM1 output on pin RC2.
After starting up the processor sets this pin high.
This is very dangerous.

Does someone know what is wrong with my code

Thanks in advance

Code:


   movlw b'00100100'
   movwf TXSTA
   movlw spbrg_value
   movwf SPBRG
   movlw b'10010111'
   movwf RCSTA


   movlw b'00000000'
   movwf CCPR1L

   MOVLW  0
   MOVWF  CCP1CON





Laughing Laughing Laughing
Ttelmah
Guest







PostPosted: Tue May 05, 2009 10:11 am     Reply with quote

Look at paragraph 16.4.2. Realise that the values won't update into the registers, till a PWM match occurs.
For 'safe' driving of a PWM, you need to add external resistors, to pull the pin when configured as an input, to the required 'off' state.
Then set TRIS so the pin is an input (default on power on).
Program the entire CCP. Setup the timer, so you know the PWM clock is running (you don't show this), then program the settings so the output would be 'off' (PWM count value = 0). Wait for one cycle of the PWM, so that the register values update, and only then set the TRIS for output.
You need hardware 'off' biasing external to the chip.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group