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 support@ccsinfo.com

[SOLVED] CCP2SEL VIA APFCON1 on PIC16f1825 not working

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



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

[SOLVED] CCP2SEL VIA APFCON1 on PIC16f1825 not working
PostPosted: Thu Apr 05, 2018 2:06 pm     Reply with quote

Hello. I'm using PCM Compiler V4.140. I'm very simply just trying to get CCP2 (PWM2 specifically) to work on PIN A5 instead of PIN C3.

I'm using the code below and it *still* makes PWM2 work on C3, even though I'm trying to set it to work with A5.

Code:


#include <16f1825.h>
#use delay(clock=32000000, int)

#byte APFCON1 = getenv("SFR:APFCON1")
#bit CCP2SEL = APFCON1.0


void main ()
{
CCP2SEL = 1;

setup_timer_2(T2_DIV_BY_1,255,1);     
setup_ccp2(CCP_PWM);
set_pwm2_duty(500);

while(1)
{
}
}



Last edited by picj1984 on Fri Apr 06, 2018 8:37 am; edited 2 times in total
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Apr 05, 2018 4:04 pm     Reply with quote

you should dump and post the listing and see what bits are being set, it could be a compiler bug.

the listing is the 'projectname.lst' file ...

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 05, 2018 8:44 pm     Reply with quote

The following program was tested with CCS vs. 4.140 and it works.
Comment out the appropriate line to switch the PWM output to pin C3 or A5.
Code:
#include <16F1825.h>
#fuses INTRC_IO, NOWDT, BROWNOUT
#use delay(clock=32M)

//==============================
void main ()
{
setup_timer_2(T2_DIV_BY_1, 255, 1);     

//setup_ccp2(CCP_PWM | CCP2_C3);
setup_ccp2(CCP_PWM | CCP2_A5);

set_pwm2_duty(128);

while(TRUE);

}
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

PostPosted: Fri Apr 06, 2018 8:36 am     Reply with quote

PCM programmer wrote:
The following program was tested with CCS vs. 4.140 and it works.
Comment out the appropriate line to switch the PWM output to pin C3 or A5.
Code:
#include <16F1825.h>
#fuses INTRC_IO, NOWDT, BROWNOUT
#use delay(clock=32M)

//==============================
void main ()
{
setup_timer_2(T2_DIV_BY_1, 255, 1);     

//setup_ccp2(CCP_PWM | CCP2_C3);
setup_ccp2(CCP_PWM | CCP2_A5);

set_pwm2_duty(128);

while(TRUE);

}


This worked for me, thank you!!
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