Page 1 of 1

Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 10:06 am
by chad
I am trying to get a 13hz pwm out of the 1501 Cant' seem to get it going at the right freq.
I set my properties in the component and enabled it. I am using channel 4 that should be RA2. I can get a 1k out but it doesn't seem to let me go below that? The display in the component looks right?

Any Ideas?

Chad

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:03 am
by QMESAR
To add what leigh said as PWM possible minimum PWM frequency is directly related to OSC frequency . another option is to use a lower OSC speed,

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:08 am
by LeighM
Sorry, I deleted my previous post because I realised that it should be possible to get a PWM in that range when the Int Osc is down at 31KHz,
which I now guess you are doing based on another post.
What is your actual result on hardware?

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:15 am
by chad
Hi Leigh,

Actually I am running at 16mhz. I was hoping that I could just set the pwn down low and let the hardware take care of blinking the led while the program did other stuff. I guess I could get creative with a timer and counters or just do it with delays..

Thanks,
Chad

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:23 am
by LeighM
Ah, right, so might deleted post applies :oops:
And as QMESAR post, the PWM max prescaler is divide by 16, and with an 8 bit counter you cannot get below that 1K.
Yes, you could consider a timer interrupt and software based counter to generate your lower frequency

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:41 am
by chad
Gotcha, I did find something else strange. Just a simple delay loop about every second I get a glitch in the output.
You can see it on the scope trace.
And this is my program.
Any Ideas?
DS1Z_QuickPrint1.png
(39.64 KiB) Downloaded 485 times
flow error glitch.jpg
flow error glitch.jpg (23.75 KiB) Viewed 3871 times
Chad

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:48 am
by LeighM
Looks like it's resetting, check watchdog timer setting

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:53 am
by chad
I turned it off and it does the same thing. Power is stable and good. Totally disconnected the programmer and it still does it.
Hmmm

Re: Can't get correct pwm speed going on PIC12f1501

Posted: Tue Nov 26, 2019 11:58 am
by chad
I think I found it. It was the brown out detection. If I disable it it doesn't reset. Very strange.

Chad