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 CCS Technical Support

ECCP for the PIC18F458

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



Joined: 04 Apr 2007
Posts: 2

View user's profile Send private message

ECCP for the PIC18F458
PostPosted: Wed Apr 04, 2007 10:00 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 10:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 11:08 am     Reply with quote

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);
}
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