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

ECCP with 16f616

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



Joined: 09 May 2014
Posts: 6

View user's profile Send private message

ECCP with 16f616
PostPosted: Fri May 09, 2014 7:57 am     Reply with quote

i have done half bridge pwm with timer 2 but because of timer2 being 8 bit timer i am not getting resolution can any one give me idea how to do this with timer 1 since it is 16 bit and in datasheet it is mentioned it can be done with timer 1 also.

Sorry for bad english and special thanks in advance
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Fri May 09, 2014 8:16 am     Reply with quote

You are misunderstanding.

The PWM always uses timer2.

Look at table 10-1 in the data sheet. Timer1, can only be used for capture or compare modes.

However your resolution is two more bits than the timer.
Timers in the PIC run off the oscillator/4. The PWM uses the raw oscillator to give two extra bits (so 10 bits from the 8 bit timer).
Look at the PWM block diagram (Fig 10-3). Note that it only shows TMR2, but then shows a little 'extra' bit attached to the right of the timer, with note '1'. Read the note.

To access these you _must_ feed the set_pwmX_duty function, with an int16. If you use an int8, you only set the high eight bits.
deepeshmishra



Joined: 09 May 2014
Posts: 6

View user's profile Send private message

PostPosted: Fri May 09, 2014 8:32 am     Reply with quote

Thank you Ttelmah
My actual problem is I needed variable frequency in half bridge mode with
50 % duty cycle
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri May 09, 2014 8:54 am     Reply with quote

got any code that compiles?

GOT SCHEMATIC of "half bridge " and connection to PIC ??

hint: for fixed 50% duty and var frequency
consider NCO instead of PWM

as in 16f1509
deepeshmishra



Joined: 09 May 2014
Posts: 6

View user's profile Send private message

PostPosted: Fri May 09, 2014 9:48 am     Reply with quote

Thanks for reference asmboy, have code for and now it is workig well. I have only problem of resolution, for that also i am trying by increasing crystal frequency.
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