|
|
View previous topic :: View next topic |
Author |
Message |
koenbielen
Joined: 23 Apr 2009 Posts: 42
|
PWM pin high after powerup |
Posted: Tue May 05, 2009 9:50 am |
|
|
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
|
|
|
|
Ttelmah Guest
|
|
Posted: Tue May 05, 2009 10:11 am |
|
|
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 |
|
|
|
|
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
|