View previous topic :: View next topic |
Author |
Message |
AJEllisuk
Joined: 03 Oct 2007 Posts: 4
|
Problems with PWM output 4 on PIC16F1827 pin RA4 |
Posted: Sun May 25, 2014 1:55 am |
|
|
Hi,
I'm working on a project to generate PWM output 4 on RA4.
The problem I have is that when I turn off PWM4 with:
Code: |
set_pwm4_duty(0);
setup_ccp4(CCP_OFF);
|
RA4 stays high, I've tried forcing it low with
Code: |
output_low(PIN_A4);
|
But that does nothing. How do I setup PWM4 so that it sets the output low when the PWM is inactive?
Kind regards
Andrew |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sun May 25, 2014 2:55 am |
|
|
Turning the CCP 'off' disables the peripheral. So the duty cycle no longer applies. Remember the duty cycle needs to be a 'long'. So simply:
set_pwm4_duty(0L);
should set the output low.
The 'priority' on this pin, is:
SR latch, PWM, T0CKI, C2OUT, RA4
So when you disable the PWM, unless T0 is set to use an internal clock, and comparator two is disabled, these will both have priority 'over' the simple pin function, stopping it from working..... |
|
|
AJEllisuk
Joined: 03 Oct 2007 Posts: 4
|
|
Posted: Sun May 25, 2014 3:39 pm |
|
|
Hi Ttelmah
Thank you for your reply; my problem is now resolved.
Kind regards
Andrew |
|
|
|