pwm_init output

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
MHI
Posts: 56
Joined: 13 Mar 2010 20:52

pwm_init output

#1 Post by MHI » 25 Mar 2010 11:17

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.

cjogo
Posts: 34
Joined: 17 May 2009 10:34
Location: UK

Re: pwm_init output

#2 Post by cjogo » 26 Mar 2010 10:27

" 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

MHI
Posts: 56
Joined: 13 Mar 2010 20:52

Re: pwm_init output

#3 Post by MHI » 28 Mar 2010 13:11

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.

cjogo
Posts: 34
Joined: 17 May 2009 10:34
Location: UK

Re: pwm_init output

#4 Post by cjogo » 28 Mar 2010 16:24

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

MHI
Posts: 56
Joined: 13 Mar 2010 20:52

Re: pwm_init output

#5 Post by MHI » 28 Mar 2010 19:16

thank you my friend :D !

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”