first you'll have to match the calc values to suit your need. With your current code example (which seems to be one of mine, the calc will give you...
<IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1593&stc=1&d=117840872 7">
look at this section of the code
Code:
duty = 52 ' duty value for 50% duty cycle
PR2 = 25 '
T2CON = %00000100 ' timer2 on, prescale 1:1
CCPR1L = duty>>2 ' MSB of duty cycle value
CCP1CON=%00001100 | (dUTY<<5) ' set PWM mode and store the
' 2 LSB of duty
52 is showned in the result section and it's to set the duty cycle to 50% as selected in the duty cyle section.
Now if you want to update the duty cycle, you could use this section
Code:
CCPR1L = duty>>2 ' MSB of duty cycle value
CCP1CON=%00001100 | (dUTY<<5) ' set PWM mode and store the
' 2 LSB of duty
in your code you just need to change the value of Duty variable.
The example was for a 16F877, you should have a look at the 12F683 to see if they work the same way.
post your whole code, maybe some register need to be set in a different way. I'll put some effort and open my datasheet as well
Last edited by mister_e; - 6th May 2007 at 00:52.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
it seems we posted at the same time, yes the post I used is from an old post of yours I used for reference. Please read my last post and tell if if you have an idea that may help me. Thanks!
Bookmarks