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

Problems with PWM output 4 on PIC16F1827 pin RA4

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



Joined: 03 Oct 2007
Posts: 4

View user's profile Send private message

Problems with PWM output 4 on PIC16F1827 pin RA4
PostPosted: Sun May 25, 2014 1:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun May 25, 2014 2:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun May 25, 2014 3:39 pm     Reply with quote

Hi Ttelmah

Thank you for your reply; my problem is now resolved.

Kind regards

Andrew
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