cannot get correct PWM frequency from PIC16F1934

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
vgershman
Posts: 7
Joined: 20 Nov 2008 02:34

cannot get correct PWM frequency from PIC16F1934

#1 Post by vgershman » 02 Dec 2011 05:51

Hi all,

I cannot setup PWM on PIC16F1934 to get 38KHZ square wave on pin RC2. I followed examples, but i get frequencies that are way off. Has anyone had issues with that? I am using microC ver 5.0

Thanks,

Brussieux
Posts: 17
Joined: 09 Dec 2011 09:48

Re: cannot get correct PWM frequency from PIC16F1934

#2 Post by Brussieux » 09 Dec 2011 09:59

Hi,
i experience same problem using mikrobasic PRO for PIC compiler, with a "Start USB" board from MikroE : the actual PWM frequency measured with an oscilloscope on pin C2 is 4 to 5 times higher than the PWM1_Init(5000) programmed 5kHz frequency.
My programmed Delay_ms() are also shorter than what expected...
Wrong clock used as reference ???

regards.

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: cannot get correct PWM frequency from PIC16F1934

#3 Post by janko.kaljevic » 12 Dec 2011 11:24

Hello,

In both cases this looks like wrong oscillator settings.
Please check Project->Edit Project for oscillator selection and settings.

Best regards.

vgershman
Posts: 7
Joined: 20 Nov 2008 02:34

Re: cannot get correct PWM frequency from PIC16F1934

#4 Post by vgershman » 13 Dec 2011 01:44

vgershman wrote:Hi all,

I cannot setup PWM on PIC16F1934 to get 38KHZ square wave on pin RC2. I followed examples, but i get frequencies that are way off. Has anyone had issues with that? I am using microC ver 5.0

Thanks,
Hello,

It was my bad. I did not set up OSCCON register. Now works like a great.

Post Reply

Return to “mikroC PRO for PIC General”