![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
mvanvliet
Joined: 02 Jun 2009 Posts: 123 Location: The Netherlands
|
16F1708 #pin_select error |
Posted: Mon Jun 08, 2015 1:21 am |
|
|
I've got an error when compiling a program for the 16F1708. Error 99 use #pin_select. But when I add this sentence in my program it doesn't compile. If I disable the setup_ccp1(CCP_PWM); the error is gone. Why is it not working?
PCW 5.026
Code: |
#include <16F1708.H>
#FUSES INTRC_IO,NOWDT
#FUSES NOPUT,NOMCLR,PROTECT,BROWNOUT,BORV25
#FUSES NOCLKOUT,NOIESO
#FUSES NOFCMEN,WRT, NOPPS1WAY
#FUSES NOSTVREN,NODEBUG,NOLVP
#Device ADC=8
#use delay(clock=8000000)
#bit T1GSEL = 285.3 // dec adress 11D Hex
#bit TMR0IF = 11.2 // TMR0 counter overflow
#bit TMR1IF = 17.0 // TMR1 counter overflow
#bit TMR4IF = getenv("BIT:TMR4IF")
#bit TMR6IF = getenv("BIT:TMR6IF")
//#PIN_SELECT P1A = pin_C5
#PIN_SELECT CCP1 = pin_C5
void main()
{
setup_oscillator(OSC_8MHZ);
setup_ccp1(CCP_PWM); // Configure CCP1 as a PWM
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); // 32,8 ms tot overflow (0.125us*4*256*256)
setup_timer_2(T2_DIV_BY_1, 255, 1); // Setup for 8 bit at 4kHz
while(1)
{
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Mon Jun 08, 2015 3:45 am |
|
|
I think you need to contact CCS.
The CCP 'input', would be CCP1 (not just CCP). However this would control the input selection, not the output.
The PWM output, would be P1A. Normally this is a separate pin (on this chip it isn't), but it does have a separate PPS entry to control the output selection. The setup_ccp 'knows' this, but the #PIN_SELECT doesn't.... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 08, 2015 10:42 am |
|
|
Quote: |
I've got an error when compiling a program for the 16F1708. Error 99 use #pin_select. But when I add this sentence in my program it doesn't compile. If I disable the setup_ccp1(CCP_PWM); the error is gone. Why is it not working?
PCW 5.026
|
Your question was discussed in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=52682
See my post for sample code. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Mon Jun 08, 2015 2:27 pm |
|
|
Unfortunately, PCM_Programmer, this is not the solution.
The syntax you give, works for PWM3, and PWM4 (the two ECCP ports), but not for the PWM1/2 ports. I remembered this thread, and went and tried and realised that PWM1 was not working. :(
I really repeat this must be reported to CCS.
Even the pin names you use,are not documented in the manual.
To 'bodge round', you have to replace the configuration functions (since otherwise the error prevents compilation. :(
It's a minor error, but one that is really annoying, and should have been fixed many compiler versions ago. Given that the earlier post about this is about eleven months old, there has been plenty of time to fix this and get the manual right as well....
If you must use CCP1, before the fix is available, this should work (not tested):
Code: |
#include <16F1708.H>
#FUSES INTRC_IO,NOWDT
#FUSES NOPUT,NOMCLR,PROTECT,BROWNOUT,BORV25
#FUSES NOCLKOUT,NOIESO
#FUSES NOFCMEN,WRT, NOPPS1WAY
#FUSES NOSTVREN,NODEBUG,NOLVP
#Device ADC=8
#use delay(clock=8000000)
#byte PPSLOCK=getenv("SFR:PPSLOCK")
#byte RC5PPS=getenv("SFR:RC5PPS")
#byte CCP1CON=getenv("SFR:CCP1CON")
#define PPSPWM 0xC //PPS register value for PWM
#inline
void unlock(void)
{
disable_interrupts(GLOBAL);
PPSLOCK=0x55;
PPSLOCK=0xAA;
bit_clear(PPSLOCK,0);
}
void main()
{
setup_oscillator(OSC_8MHZ);
unlock();
RC5PPS=PPSPWM; //set the CCP1 pin as PWM output
//setup_ccp1(CCP_PWM);
CCP1CON=CCP_PWM; //replacement for setup_ccp, that ignores the PPS
output_drive(PIN_C5); //since I am controlling the pin also control TRIS
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); // 32,8 ms tot overflow (0.125us*4*256*256)
setup_timer_2(T2_DIV_BY_1, 255, 1); // Setup for 8 bit at 4kHz
while(1)
{
}
}
|
No guarantees, but I think this ought to be close. |
|
![](templates/subSilver/images/spacer.gif) |
mvanvliet
Joined: 02 Jun 2009 Posts: 123 Location: The Netherlands
|
|
Posted: Tue Jun 09, 2015 1:55 am |
|
|
The solution came from CCS support:
Quote: |
As long as you use #pin_select CCP1OUT=PIN_xx to assign the pin when setting up the CCP1 peripheral for PWM or Compare mode, or #pin_select CCP1=PIN_xx to assign the pin when setting up the CCP1 peripheral for Capture mode then it should compile correctly.
If you're use the CCP2 peripheral then you would use #pin_select CCP2OUT=PIN_xx to assign the pin when setting it up for PWM or Compare mode, or #pin_select CCP2=PIN_xx to assign the pin when setting it up for Capture mode.
|
The solution is to use CCP1OUT instead of P1A which the compiler suggests. This CCP1OUT is also not described in the CCS manual, not in the 16F1708.h and not in the 16F1708 datasheet, so not easy to find... |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Tue Jun 09, 2015 2:06 am |
|
|
Hurrah.
They really need to have pointed out to them, that 'failing' updating the manual (which should be done ASAP), the names should be given in a 'PPSNAMES.TXT' included with the compiler.
Suggest this to them.
One could spend 'forever' trying to guess the names (or have to sit down with a debugger and work through their code looking for them!).
It's even funnier, since the thread PCM_programmer pointed to, had the name for PWM2/4, as 'PWM3OUT' (and 4 out). Duh... |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|