View previous topic :: View next topic |
Author |
Message |
Noland
Joined: 11 Dec 2011 Posts: 11 Location: Thailand
|
16F1826 how to setup PWM |
Posted: Wed Jan 04, 2012 9:47 am |
|
|
CCS V.4.107 PIC16F1826 Undefined identifier -- setup_ccpx I need use PWM. how to setup PWM
Code: | include <16F1826.H>
#fuses INTRC_IO,NOLVP,NOWDT,NOPROTECT,MCLR
#use delay(clock=32M)
#byte CCPR3L = 0x311
#byte CCPR4L = 0x318
#byte CCP3CON = 0x313
#byte CCP4CON = 0x31A
int8 i;
int16 cnt;
#define delay_ms(x) \
cnt = x; \
while(cnt) \
{ \
for(i=0; i<8; i++) \
{ \
delay_cycles(250); \
delay_cycles(250); \
delay_cycles(250); \
delay_cycles(250); \
} \
cnt--; \
}
//========================================
void main()
{
setup_ccp3(CCP_PWM); //compiler Undefined identifier
setup_ccp4(CCP_PWM); //compiler Undefined identifier
setup_timer_2(T2_DIV_BY_16,255,1);
while(TRUE)
{
.
.
.
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19384
|
|
Posted: Wed Jan 04, 2012 10:01 am |
|
|
Look at the data sheet.
Table 24-1
What does it say about CCP3, and CCP4?.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Noland
Joined: 11 Dec 2011 Posts: 11 Location: Thailand
|
|
Posted: Wed Jan 04, 2012 10:57 am |
|
|
16f1826 have CCP1 only |
|
![](templates/subSilver/images/spacer.gif) |
|