View previous topic :: View next topic |
Author |
Message |
nightmare619
Joined: 04 Apr 2007 Posts: 2
|
ECCP for the PIC18F458 |
Posted: Wed Apr 04, 2007 10:00 am |
|
|
Processor: 18F458
Speed: 10MHz
Compiler Version: 3.234
Hello all, I need some help using the CCS compiler to set up the ECCP on my 18f458. Looking at the data sheet I see that it is possible to set up the ECCP in standard mode (it works like CCP1) by using the same process as setting up CCP1. However, the compiler does not seem to handle setting up the ECCP. Can I use the standard setup_ccpX() command?
I also thought that I could possibly generate the code for setup_ccp1(CCP_PWM) and copy it to work for setting up the ECCP since it can be done by the same process except using port D. |
|
|
nightmare619
Joined: 04 Apr 2007 Posts: 2
|
|
Posted: Wed Apr 04, 2007 10:22 am |
|
|
This is what I get from compiling the setup_ccp1(CCP_PWM) command, I don't quite understand what is going on here without studying the assembly code a bit more. So, if anyone thinks this is a viable option please tell me how to modify this code accordingly.
.................... setup_ccp1(CCP_PWM);
001E: MOVLW B7
0020: ANDWF FB1,F
0022: BCF F94.2
0024: BCF F8B.2
0026: MOVLW 0C
0028: MOVWF FBD |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 04, 2007 11:08 am |
|
|
Use the CCS functions for CCP2. The program below will provide
PWM output on the ECCP1 pin.
Code: |
#include <18F458.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//=======================
void main()
{
setup_timer_2(T2_DIV_BY_1, 255,1);
setup_ccp2(CCP_PWM);
set_pwm2_duty(127);
while(1);
} |
|
|
|
|