• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

these K series are a pain


Well-Known Member
Most Helpful Member
Sorry. I can't tell what you've done from what you've posted.

What I posted works and somehow you have managed to screw it up from the first line on. You may have got some non-printing characters in what you've copied.

Use white space. It's your friend. The indents make the structure clear. Blank lines separate sections.

Try copying the entire block into Notepad, then copy it from Notepad into Swordfish. This usually gets rid of garbage characters.
Last edited:


Well-Known Member
Most Helpful Member
I tried to compile what I had listed. Apparently, the 18F23K20 doesn't follow the same parameters as the rest of the K-series. Not "every line failed" but 6 of the 17 compiler directives have errors. They are commented out in the first column in the code shown below.

So what does this mean? Either the compiler directive has a different name in the K20 devices, or it has different allowable values. How could we figure that out? The smart money would be to look in the data sheet.

FOSC is the oscillator mode. Looking in the data sheet gives us 2 clues:

o HSHP isn't an allowable mode for the K20

o The PLL is configured in the FOSC section rather than as a separate parameter.


The smart money is working your way through the list and setting the parameters correctly. But you, I and everybody else here knows you'll just delete the lines that result in errors and be on your jolly way and it will probably work well enough. Sorry I tried to help and added some confusion. Also sorry I worry about things like understanding why things don't work so I can have reliable code. "It's never done that before" may be ok for your stuff, but it's not for mine.

DEVICE = 18F43K20
Config 'for K-series device
'   FOSC = HSHP ,'HS oscillator (high power > 16 MHz)
'   PLLCFG = Off ,'Oscillator used directly
'   PRICLKEN = Off ,'Primary clock can be disabled by software
    FCMEN = Off ,'Fail-Safe Clock Monitor disabled
    IESO = Off ,'Oscillator Switchover mode disabled
    'PWRTEN = Off ,'Power up timer disabled
'   PWRTEN = on ,'Power up timer enabled
    BOREN = Off ,'Brown-out Reset disabled in hardware and software
    'BOREN = on ,'Brown-out Reset enabled
'   BORV = 285 ,'VBOR set to 2.85 V nominal
    WDTEN = Off ,'Watch dog timer is always disabled. SWDTEN has no effect.
    WDTPS = 256 ,'1:256
    PBADEN = Off ,'PORTB<5:0> pins are configured as digital I/O on Reset
    HFOFST = Off ,'HFINTOSC output and ready status are delayed by the oscillator stable status
'   MCLRE = EXTMCLR ,'MCLR pin enabled, RE3 input pin disabled
    STVREN = On ,'Stack full/underflow will cause Reset
    'LVP = On ,'Single-Supply ICSP enabled if MCLRE is also 1
    LVP = Off ,'Single-Supply ICSP disabled
    XINST = Off ,'Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
    Debug = Off'Disabled
INCLUDE "SetDigitalIO.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "utils.bas"
INCLUDE "convert.bas" //xxxxx 
INCLUDE "Utils.bas"
INCLUDE "SetDigitalIO.bas"


Well-Known Member
Thread starter #25
ran the config gen and now need to do some research into settings. I assume the modules set things up slightly different?
going to do some comparisons etc.
mean while, back at the ranch, trying to get the suggested BOOLEAN code suggestion to work right.


Well-Known Member
Most Helpful Member
Not being funny but, shouldnt your dry joints take care of a LED blinking? Forget the code, just solder it up :D

yes yes yes i know, off i go to self flagellate


Well-Known Member
Most Helpful Member
Hi jonsea, yeah its likely i will be about for a little while, i got a project to finish. Starting work for myself got really busy, alot more busy than i thought. I like being self employed but it eats every hour your awake.


Well-Known Member
Most Helpful Member
There are some nice things aboit working for yourself. But it can and will definitely consume every waking moment if you let it. You might try setting some times that are "you time" with no business during you time no matter what.

But I know you'll do well at anything you set your mind to!


Well-Known Member
Most Helpful Member
We are months behind schedule, mainly because I didnt expect 99% of the problems that crop up. Licenses and paperwork have been a nightmare, I have a website ready to go. Funny thing is I also have an abandoned one one the same address! I keep meaning to delete it and just put the new one up. But until I am ready for more production I didnt want more orders. I was going to make do, but in the end decided to just go for it and build a dedicate space.

I try and get time, but I went the LTD route, like your Inc..... We will be selling in the states pretty soon, i was going to at Christmas but pulled it at the last minuet. I found some things out on the importation rules, no choice but to pull out at the last min. I have it sorted out now, yeah its been really hard and the legal side is a minefield. money is up and down, its alot of responsibility and scary at times. But I wouldnt work for anyone else!

I am a great boss! I get coffee breaks whenever I want, and I allow myself paid lunch!! I didnt get a christmas bonus off myself this year, but maybe next!

Sorry Mr D i nearly took the thread off topic.

As you were chaps, back to work


Well-Known Member
Most Helpful Member
Keep up the good efforts LG. Sounds like you having amazing things going on. Much success to you.

Funny, working for myself, I seem to have a real a-- hole for a boss ;)


Well-Known Member
Most Helpful Member
Keep up the good efforts LG. Sounds like you having amazing things going on. Much success to you.

Funny, working for myself, I seem to have a real a-- hole for a boss ;)
So is mine really, but he is always listening in to my conversations ;).


Well-Known Member
Thread starter #34
I have found "talking to ones self" out-loud and questioning what I am doing helps get things going as planed and avoids the boredom that you may encounter being the lone employee.
At present I have three different projects going at the same time so you get hung up on one then go to another and you will find that ideas will to solve a problem might materialize.
Good Luck on your venture

EE World Online Articles