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 CCS Technical Support

pic 24F and period of Pwm [solved]

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



Joined: 21 Dec 2011
Posts: 42

View user's profile Send private message

pic 24F and period of Pwm [solved]
PostPosted: Sun Sep 09, 2012 8:41 am     Reply with quote

Hi,

I'm working on a motor control with a PWM brigh power. My Pic is 24Fj128g104, my ccs is 4.128.

I'm trying to set the period of my pwm signal but i encounter a problem : In spite of value, the period is always the same...

this is my fuses :
Code:

#include <24FJ64GA104.h>
#DEVICE *=16
#device adc=10
#fuses FRC_PLL,NOWDT
#FUSES ICSP2      
#FUSES NOIOL1WAY    //Allows multiple reconfigurations of peripheral pins
#FUSES OSCIO        //OSC2 is general purpose output
#FUSES SOSC_IO      //SOSC0/RA4
#FUSES NOPR         //Pimary oscillaotr disabled
#use delay(clock=32M,internal)


this is my code...
Code:
 setup_timer2(TMR_INTERNAL|TMR_DIV_BY_1,100);
   setup_compare(1,COMPARE_PWM_EDGE | COMPARE_TIMER2 );
   setup_compare(2,COMPARE_PWM_EDGE | COMPARE_TIMER2 );
   set_pwm_duty(1,1000);
   set_pwm_duty(2,1000);


Now i able to change the duty cycle with change value of "Set_pwm_duty", but anything for the period.

If anyone have an idea ???
thanks in advance
joseph20480



Joined: 21 Dec 2011
Posts: 42

View user's profile Send private message

PostPosted: Sun Sep 09, 2012 9:52 am     Reply with quote

Hi,

It's seem to be solved !!

http://www.ccsinfo.com/forum/viewtopic.php?p=113418

setup_compare was wrong
... you must write this
Code:

setup_compare(1, COMPARE_PWM_EDGE | COMPARE_TIMER2 | COMPARE_TRIG_SYNC_TIMER2);

instead of
Quote:

setup_compare(1,COMPARE_PWM_EDGE | COMPARE_TIMER2 );
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