PIC12f1840 speed selection

For general Flowcode discussion that does not belong in the other sections.
Post Reply
alanwms
Posts: 147
http://meble-kuchenne.info.pl
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

PIC12f1840 speed selection

Post by alanwms »

Flowcode version 9.

Running a short program at project option speed 32 (mhz). Delay times are double expected time. I changed to project option time to 20 mhz and the delay times are correct.

FYI

medelec35
Matrix Staff
Posts: 2148
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 662 times
Been thanked: 725 times

Re: PIC12f1840 speed selection

Post by medelec35 »

Hi.
Sounds like you have not set up the internal oscillator correctly.
Take a look at the Wiki.
Martin

alanwms
Posts: 147
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: PIC12f1840 speed selection

Post by alanwms »

If the system timing is correct at 20mhz, would that not indicate internal oscillator to be correct?

chipfryer27
Valued Contributor
Posts: 1757
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 387 times
Been thanked: 598 times

Re: PIC12f1840 speed selection

Post by chipfryer27 »

Hi

If you mean where you can select clock speed under project options (highlighted yellow) then that only tells Flowcode what speed you are running at, not the hardware. You still need to select that (highlighted green) and possibly add in a C-code block.

Screenshot 2025-09-10 154934.jpg
Screenshot 2025-09-10 154934.jpg (103.25 KiB) Viewed 2405 times


If you post your chart we can look further.

Regards

alanwms
Posts: 147
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: PIC12f1840 speed selection

Post by alanwms »

Thank you. I think I have selected the correct register number for the osc? Maybe not? I have attached my file
Attachments
PWM CODE.fcfx
(18.46 KiB) Downloaded 83 times

chipfryer27
Valued Contributor
Posts: 1757
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 387 times
Been thanked: 598 times

Re: PIC12f1840 speed selection

Post by chipfryer27 »

Hi

Have a look at the attached snippet from Datasheet. It illustrates the available options you can select using the internal oscillator. If you choose one of them then you should be good. 20MHz would only be an option if using an external crystal.

Flowcode has the Internal Oscillator Helper under Runtime, and this will tell you the code to use in your C-block for your chosen IntOsc, and of course don't forget to set your clock speed to match, under "Other Options" as this tells FC what frequency you are running.

Screenshot 2025-09-11 194148.jpg
Screenshot 2025-09-11 194148.jpg (61.73 KiB) Viewed 2384 times

Regards

Post Reply