View previous topic :: View next topic |
Author |
Message |
picj1984
Joined: 01 Mar 2010 Posts: 73
|
[SOLVED] CCP2SEL VIA APFCON1 on PIC16f1825 not working |
Posted: Thu Apr 05, 2018 2:06 pm |
|
|
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: 9245 Location: Greensville,Ontario
|
|
Posted: Thu Apr 05, 2018 4:04 pm |
|
|
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
|
|
Posted: Thu Apr 05, 2018 8:44 pm |
|
|
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
|
|
Posted: Fri Apr 06, 2018 8:36 am |
|
|
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!! |
|
|
|