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

Pic24FJ16MC102 Motor PWM function problem

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



Joined: 16 Jan 2011
Posts: 27

View user's profile Send private message

Pic24FJ16MC102 Motor PWM function problem
PostPosted: Fri Apr 24, 2015 3:26 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 6:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 25, 2015 11:46 am     Reply with quote

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

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