Page 1 of 1

cannot get correct PWM frequency from PIC16F1934

Posted: 02 Dec 2011 05:51
by vgershman
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,

Re: cannot get correct PWM frequency from PIC16F1934

Posted: 09 Dec 2011 09:59
by Brussieux
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.

Re: cannot get correct PWM frequency from PIC16F1934

Posted: 12 Dec 2011 11:24
by janko.kaljevic
Hello,

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

Best regards.

Re: cannot get correct PWM frequency from PIC16F1934

Posted: 13 Dec 2011 01:44
by vgershman
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.