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 support@ccsinfo.com

18f4580 PWM config

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



Joined: 15 Oct 2011
Posts: 36

View user's profile Send private message

18f4580 PWM config
PostPosted: Sun Dec 16, 2012 8:20 am     Reply with quote

Hello,
I need a PWM on pin P1A(RD4). This is output ECCP.
I don't know how I must configure this module.

I tried something like this:
Code:

// TImer2 used for system ticks
// post = 4, period = 250*4*5* 0.2 us = 1 ms

#define T2CON_CONST     T2_DIV_BY_4       
#define PR2_CONST       (250-1)     
#define T2POST_CONST    5

setup_timer_2(T2CON_CONST, PR2_CONST, T2POST_CONST);

SETUP_CCP1(CCP_PWM_H_H);

SET_PWM1_DUTY(100);


But not working.

Best regards
R.L.
Ttelmah



Joined: 11 Mar 2010
Posts: 19346

View user's profile Send private message

PostPosted: Sun Dec 16, 2012 10:13 am     Reply with quote

The ECCP is reverse compatible. To use the default pin, just use:

SETUP_CCP1(CCP_PWM);

Key thing is though, you must have turned off the PSP port:

SETUP_PSP(PSP_DISABLED);

or this will have control of the port pins.

Best Wishes
Lemosek



Joined: 15 Oct 2011
Posts: 36

View user's profile Send private message

PostPosted: Sun Dec 16, 2012 11:37 am     Reply with quote

Hello,
Thank You Ttelmah now it's working but I must also change CCP1 to CCP2.

Best regards
R.L.
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