PIC16F18346 and OSCCON

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

Moderator: Benj

Post Reply
Frank607
Posts: 192
Joined: Mon Mar 04, 2013 8:07 pm
Has thanked: 29 times
Been thanked: 15 times
Contact:

PIC16F18346 and OSCCON

Post by Frank607 »

Hi,

I have a problem with running my PIC16F18346 on 8Mhz. I get this error:

Code: Select all

PIC16F18346 - OSCCON - 01.c: main()
   322:	OSCCON = 0x70;
^ (192) undefined identifier "OSCCON"
(908) exit status = 1
(908) exit status = 1
I don’t understand why. I use only the internal oscillator. I have tried the three options for internal oscillator but nothing helps.
I also used "OSCCON = 0x70" without spaces.

Attached the simple Flowchart.
PIC16F18346 - OSCCON - 01.fcfx
(11.58 KiB) Downloaded 103 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: PIC16F18346 and OSCCON

Post by medelec35 »

Hi Frank,
Unfortunately, Microchip decided to change the name of the register from OSCCON to OSCFRQ
So the OSCCON part requires removing.
Now what you need to do is within the configuration settings is select HFINTOSC32MHz
The C block at the start requires a value for OSCFRQ which is found within the datasheet on page 93:
16F18346 Datasheet.png
16F18346 Datasheet.png (114.05 KiB) Viewed 1165 times
The frequency selected can be from 1 to 32MHz.
So as you want 8MHz you can see that the value is 0100.
Since that it's 4 you can use hex:

Code: Select all

OSCFRQ = 0x4;
or decimal:

Code: Select all

OSCFRQ = 4;
or even binary:

Code: Select all

OSCFRQ = 0b0100
It's vital that you check by using a one-second flasher test to make sure the mico is running at the correct speed.
Martin

Frank607
Posts: 192
Joined: Mon Mar 04, 2013 8:07 pm
Has thanked: 29 times
Been thanked: 15 times
Contact:

Re: PIC16F18346 and OSCCON

Post by Frank607 »

Hi Martin,

I can only say WOW !! and thanks for this great explanation. I could in no way find this solution.

I will try this tomorrow morning and let you know.

(the one flasher test I use every time with a scoop for a new chip)

Post Reply