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

PWM on pic 24fj256ga106

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



Joined: 25 Sep 2013
Posts: 1

View user's profile Send private message

PWM on pic 24fj256ga106
PostPosted: Wed Sep 25, 2013 2:54 am     Reply with quote

I' ve tried using pwm on device pic 24fj256ga106. I've tried the #use PWM and also setup_compare(). However, the simulation proteus doesn't display the pwm. Here are my code:
Code:

#include "24FJ256GA106.h"
#use delay(CLOCK=8000000)
#pin_select OC2  = PIN_B6
#pin_select OC1  = PIN_B1

void main(void) {

 setup_timer2(TMR_INTERNAL|TMR_DIV_BY_1,1000);
   setup_compare(1,COMPARE_PWM_EDGE | COMPARE_TIMER2 | COMPARE_TRIG_SYNC_TIMER2);
   setup_compare(2,COMPARE_PWM_EDGE | COMPARE_TIMER2 | COMPARE_TRIG_SYNC_TIMER2 );
   set_pwm_duty(1,200);
   set_pwm_duty(2,200);
while(1);
}


And this is the #use PWM():
Code:

#include "24FJ256GA106.h"         // Modify for your chip
#use delay(crystal=20000000)   // Modify for your clock and freq
#use PWM(OUTPUT=PIN_B1,FREQUENCY=10Khz,DUTY=25)

void main(void) {
PWM_ON();
setup_timer2(TMR_INTERNAL |TMR_DIV_BY_8 ,20000);
set_pwm_duty(1,855);


while(1);
}

can anyone help me? I'm stuck now. I have to control 18 rc servo in a spider robot. This chip provide 9 pwm with a high resolution, so I chose it. This just the sample code to simulate in proteus, to see if i can controll any servo. Please help me! Sad
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Wed Sep 25, 2013 3:25 am     Reply with quote

NO MORE PROTEUS!

http://www.ccsinfo.com/forum/viewtopic.php?t=47549
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Wed Sep 25, 2013 8:30 am     Reply with quote

As a comment though, I'm not sure using the same timer to generate the PWM, and as the sync source is legitimate. Since PWM, is already generated from the timer, just use the timer, don't try to sync to it as well.

Best Wishes
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