View previous topic :: View next topic |
Author |
Message |
Lemosek
Joined: 15 Oct 2011 Posts: 36
|
18f4580 PWM config |
Posted: Sun Dec 16, 2012 8:20 am |
|
|
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: 19515
|
|
Posted: Sun Dec 16, 2012 10:13 am |
|
|
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
|
|
Posted: Sun Dec 16, 2012 11:37 am |
|
|
Hello,
Thank You Ttelmah now it's working but I must also change CCP1 to CCP2.
Best regards
R.L. |
|
|
|