|
|
View previous topic :: View next topic |
Author |
Message |
pieter
Joined: 16 Jan 2011 Posts: 27
|
Pic24FJ16MC102 Motor PWM function problem |
Posted: Fri Apr 24, 2015 3:26 am |
|
|
Hi Guys,
I have a Pic24FJ16MC102 pcb that runs well except I can not get the MOTOR PWM function to work. I use H and L of PWM pair set no 1.
I have tried all logical combinations of:
Code: |
#FUSES NOPWMLOCK
#FUSES PWMPIN // tried with and without
setup_motor_pwm(1,MPWM_FREE_RUN,4,0,0x7FFF); // tried various options
set_motor_unit(1,1,MPWM_ENABLE | MPWM_FAULT_NO_CHANGE,100,100);
set_motor_pwm_duty(1,1,0x7FFF); //Set pin pair 1 to a 50% duty cycle.
|
Toggling the pins with i/o commands work but with the above PWM functions, all is quiet.
Am I overlooking something?
Thanks for help. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 24, 2015 6:14 pm |
|
|
Since no one else has answered, I will try to help (I don't have the PCD compiler).
Here is an example from Eduardo. It's for the dsPIC30, but it's similar
and may work with your PIC.
Example using motor PWM with dsPIC30F2010:
http://www.ccsinfo.com/forum/viewtopic.php?t=51642 |
|
|
pieter
Joined: 16 Jan 2011 Posts: 27
|
|
Posted: Sat Apr 25, 2015 11:46 am |
|
|
Thank you, I have just about tested every option including from the example to mention. It does not work.
I had to revert back to simple PWM functioning.
However, to get it going on this chip, here are the required fuse settings:
Code: |
#FUSES NOPWMLOCK //PWM Change Unlocked
#FUSES NOPWMPIN // Define PWM pin after reset
#pin_select OC1= Pin_B14 // Assign functions to pins
#pin_select OC2= Pin_B15
Setup_Timer2(Tmr_Internal | Tmr_div_by_256, 288);
Setup_Compare(1,COMPARE_PWM | COMPARE_TIMER2);
SET_PWM_DUTY(1,144); // 50% dc
Setup_Compare(2,COMPARE_PWM | COMPARE_TIMER2);
SET_PWM_DUTY(2,72); // 25% dc
|
|
|
|
|
|
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
|