clock settings for 18F24k22 do not work for 18F14k22 ?

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
LEEDNH
Posts: 42
Joined: Fri Feb 03, 2017 8:44 pm

clock settings for 18F24k22 do not work for 18F14k22 ?

Post by LEEDNH » Thu Feb 23, 2023 10:41 pm

Device = 18F24k22 'using Vdd = 3.3 or 5.0 volts
Clock = 64 'using 16 MHz x4 = 64
Config FOSC = HSHP
Config PLLCFG = ON

The lines above compile just fine

Changing the processor from 18F24K22 TO 18F14K22

CAUSES ERRORS ON THE Config FOSC - HSHP line

Device = 18F14k22 'using Vdd = 3.3 or 5.0 volts
Clock = 64 'using 16 MHz x4 = 64
Config FOSC = HSHP
Config PLLCFG = ON

Message=Compilation errors
Image=3
[COMPILE_ERROR]
ITEM_0="C:\Users\User\Documents\Swordfish\18F14k22 NEW.bas","22","15","Invalid option : HSHP"
ITEM_1="C:\Users\User\Documents\Swordfish\18F14k22 NEW.bas","23","8","Identifier not declared : PLLCFG"

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: clock settings for 18F24k22 do not work for 18F14k22 ?

Post by Jerry Messina » Fri Feb 24, 2023 1:31 pm

Each device has it's own set of CONFIG settings, and many times they're different.
The choices are spelled out in the datasheet, usually in a chapter titled "Special Features of the CPU".
They're also called out at the end of the device .bas file in the 'Includes' folder (ie "18F14K22.bas")

The easy way is to use the ConfigGenerator plugin to see the different options.
It'll generate the code for you, which you can paste into your file.

I think the equivalent settings for a 14K22 would be:

Code: Select all

device = 18F14K22

config
    FOSC = HS,          // HS oscillator
    PLLEN = ON         // Oscillator multiplied by 4
Watch out using the 14K22... that chip has some nasty peripheral errata that they've never seen fit to fix.

LEEDNH
Posts: 42
Joined: Fri Feb 03, 2017 8:44 pm

Re: clock settings for 18F24k22 do not work for 18F14k22 ?

Post by LEEDNH » Sat Feb 25, 2023 2:30 am

Hi Jerry

Thanks very much. I should know better than to assume with Microchip. It seemed logical that the same family of devices would have similar configs and what works for the 44k22 and 24k22 would work for the 14k22. I shall use the config steadfastly from here on. Thanks also for the tip on errata.
I wouldn't go near a pic device without the compiler but it is nice that they still produce the dual in line packages...

Thanks again
Lee

LEEDNH
Posts: 42
Joined: Fri Feb 03, 2017 8:44 pm

Re: clock settings for 18F24k22 do not work for 18F14k22 ?

Post by LEEDNH » Sat Feb 25, 2023 4:25 am

Hello

Here is the link to the 18F14k22 Silicon Errata and Data Sheet Clarification which I believe Jerry was referencing...

https://ww1.microchip.com/downloads/aem ... 00437H.pdf

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: clock settings for 18F24k22 do not work for 18F14k22 ?

Post by Jerry Messina » Sat Feb 25, 2023 12:48 pm

Yeah, you would think a "K22 is a K22", but sadly that's not the case... there are at least three different datasheets for the "K22 family".

One thing I've learned is to never assume ANYTHING with Microchip!

LEEDNH
Posts: 42
Joined: Fri Feb 03, 2017 8:44 pm

Re: clock settings for 18F24k22 do not work for 18F14k22 ?

Post by LEEDNH » Sun Feb 26, 2023 8:05 am

Hi Jerry,

Or as I just discovered, I could have used your include file: Include "intosc.bas". it works the same for the 24k22 or 14k22 and I don't have to solider a resonator and 1meg resistor. I really need to do more snooping on the home page as well as here...

Thanks again
Lee

Post Reply