Page 1 of 1

pwm_init output

Posted: 25 Mar 2010 11:17
by MHI
hello all, i have a little question.

when creating pwm with the function pwm_init, let's say for example:
period= pwm_init(50,1,1,2) ( freq=50 Hz, channel=1, prescaler=1, timer2), so the peiod much me equal to 1/50=20ms.
but the output period is :6783 !!!

Another example:
if period =pwmm_init(500,1,1,2) so i changed the frequency to 500 hz, then period should be 1/500=2ms.
but the output is :39999 !!!

Does anyone understand what are these numbers ? and what kind of logic they follow, please reply

Best Regards.

Re: pwm_init output

Posted: 26 Mar 2010 10:27
by cjogo
" freq_hz: PWM frequency in Hz (refer to device datasheet for correct values in respect with Fosc)" This has been quoted from the help files.

Therfore according to the help files the PWM period depends on Fosc. What processor and clock are you using?

Jogo

Re: pwm_init output

Posted: 28 Mar 2010 13:11
by MHI
hello cjogo, thanks for your reply.

I am experimenting this on a dspic pro 4 board, so the microcontroller is dspic 30f6014A, the clock that i am using in the mikroc dspic software is 80 MHZ, and when programing i use a XT w/PLL 8x - XT crystal osc, mode 8x PLL enabled.

honestly, I don't really understand what these values should be ?

thanks again.

Re: pwm_init output

Posted: 28 Mar 2010 16:24
by cjogo
Hello MHI,

Check out this link please which I must thank mikroElektronika for making available to all.

http://www.mikroe.com/en/books/dspicboo ... ch6/#ch6.4

I get most of my info from this book... Well worth it!!!

Jogo

Re: pwm_init output

Posted: 28 Mar 2010 19:16
by MHI
thank you my friend :D !