View previous topic :: View next topic |
Author |
Message |
deepeshmishra
Joined: 09 May 2014 Posts: 6
|
ECCP with 16f616 |
Posted: Fri May 09, 2014 7:57 am |
|
|
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: 19587
|
|
Posted: Fri May 09, 2014 8:16 am |
|
|
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
|
|
Posted: Fri May 09, 2014 8:32 am |
|
|
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
|
|
Posted: Fri May 09, 2014 8:54 am |
|
|
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
|
|
Posted: Fri May 09, 2014 9:48 am |
|
|
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. |
|
|
|