Can't get correct pwm speed going on PIC12f1501

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Can't get correct pwm speed going on PIC12f1501

Post 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

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

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

Post 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,

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post 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?

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

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

Post 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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post 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

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

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

Post 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 3456 times
Chad

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post by LeighM »

Looks like it's resetting, check watchdog timer setting

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

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

Post 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

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

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

Post by chad »

I think I found it. It was the brown out detection. If I disable it it doesn't reset. Very strange.

Chad

Post Reply