Page 1 of 1

PIC16F18346 and OSCCON

Posted: Sun Aug 01, 2021 5:26 pm
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 109 times

Re: PIC16F18346 and OSCCON

Posted: Sun Aug 01, 2021 6:30 pm
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 1324 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.

Re: PIC16F18346 and OSCCON

Posted: Sun Aug 01, 2021 6:36 pm
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)