need more example PWM using pcd for DSPIC33FJ256MC710
Posted: Tue Feb 26, 2008 11:52 pm
hi, can any one send me other example of PWM using pcd for DSPIC33FJ256MC710. the example in picc is not very helpful.
i need more example:
my problem is which pin is my pwm output??
how to setup pwm -40khz??
Here is the thing i can't understand from example:
/* PWM EXAMPLE FOR 16-BIT PICS */
do {
// The cycle time will be (1/clock)*4*t2div*(period+1)
// In this program clock=20000000 and period=127 (below)
// For the three possible selections the cycle time is:
// (1/20000000)*4*1*65473 = 13.1 ms or 76.37 hz
why here not using 128 and why 65473???
// (1/20000000)*4*8*65473 = 104.7 ms or 9.55 hz
// (1/20000000)*4*64*65473 = 838.1 ms or 1.19 hz
case '1' : setup_timer2(TMR_INTERNAL | TMR_DIV_BY_1, 0xFFC0);
setup_compare(1, COMPARE_PWM | COMPARE_TIMER2);
set_pwm_duty(1,value * (int16)64);
what this part means??
can i just put
mtspeed is my adc in put
set_pwm_duty(mtspeed);
Thank you.
Guest
Posted: Fri Mar 07, 2008 7:32 am
setup_timer2(TMR_INTERNAL | TMR_DIV_BY_1, 750); //set period to 750 for 40kHz PWM at 120MHz
setup_compare(2, COMPARE_PWM | COMPARE_TIMER2); // firts number that is 2 sets OC2 PIN (1 for OC1...etc)
set_pwm_duty(2,value); // value must be lower than period(0-750)
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