Continue to Site

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.

  • 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.

pickit2 and 18f43K22

Status
Not open for further replies.
THANKS Tumbleweed, the code using the LCD works good but seems faster using the crystal (I have a reaction time code)
 
I do not own a smart phone, only a flip phone. I realized that I was comparing the reaction time using two different devices. the 18f4321 and the 18f43k22.
Going to test against the stop watch on the flip phone
After I test then will try using the crystal osc since I have 20 of them ordered. I figured that using a crystal would give a more accurate ET reaction than the internal osc.
 
This looks like the issue MrDEB attacked so assiduously in April 2018.

And just now in January 2020.

There are more accurate ways to measure elapse time with a PIC controller but they can be complex to setup.

These methods involve TIMER1 and the CCP in capture mode to count the number of instruction cycles between the start and stop events.

Ask a Swordfish BASIC expert if there is example code for using the CCP in capture mode.
 
the code using the LCD works good but seems faster using the crystal
It probably would. I set the osc for 8MHz just to get things up and running.
In the example code I posted try changing the line:
Code:
clock = 8
to
Code:
clock = 64
and see if that works faster for you.

You don't need a crystal for what you're doing. They're a waste of money and effort for what you do.
 
Personally, I always use a crystal. With Swordfish, they just work where sometimes the internal oscillator can cause issues with the order of include files and start up actions. The "waste of money" (less than 25 cents) is worth the cost on terms of reliability and simplicity of making things work. Sometimes, I need the higher speed and accuracy afforded by using a crystal.

I'm lazy (any number of people here would be happy to provide additional negative descriptors) and have pretty much standardized my PIC18F-design; the use of a crystal is part of that design.

I also always include a reset switch in my designs. Not often needed but lifesaver when it is. Particularly with a 40 pin chip, disabling /MCLR is almost inconceivable to me.

My personal opinions only, based on my experiences and inherent lazy nature.
 
When using the internal oscillator you need a small include file first or things like initializing an LCD will be run at 32k and can take 10 minutes to execute due to the delays. As long as you understand that, the internal oscillator is fine for most things.

Mike.
 
On a side note... Each crystal needs power from within the micro.... High Speed crystals need different power than XT crystals...

If you have --> 4mhz use the XT setting and 8mhz--> use HS setting... I cannot get a micro to run at 20Mhz on the XT setting.
 
I've seen swordfish take hours for LCD to start up if you google you'll find post from years ago that tell all about this.

You got set the clock setting before any modules load oscon setting being first

Crystal you don't have that problem like you do with internal osc

Bet this been said 1000 of times

I started using the 18f1220 think that's right it's been 10 years went to work left the thing setting and running can back and it was happily showing the text on lcd.

The module code was running at 32 kg like mike said that's why if you read over at swordfish you'll see how to add and use the
Oscon.bas module
 
A lot of valid points... you SHOULD include "intosc.bas" first so its initializer runs before others, otherwise you'll be running at the default freq (which is 1MHz for the K22) until the initializer has a chance to change it.

If you update to the latest SF version all of this will be done automatically for you... no additional statements have to be added
(with the exception of adding 'include "intosc.bas"'). V2.2.3.0 has a number of additions to the library modules to bring them up to date with some of the newer devices that have been added.

I recommended using the int osc since, in my experience, it "just works", and datasheets and config statements are NOT MrDEB's strong suit.

If MrDEB would-
a). update his compiler (Help | About... | Check for updates)
b). throw away all his old chips and just use the 18F2xK22/4xK22

Then maybe we wouldn't end up with these "I can't blink an LED" posts every year as he randomly changes things he has no idea about.

Recommendations for MrDEB tend to be vastly different than other users.
 
Last edited:
It's like at work we run 1000 of wires if you take notes hook things up top down
It runs

But when you take 5 people's notes mix some up wrong they call me lol

You can't just keep mixing in parts the wrong way
 
All valid points.
Going to use the internal osc. Just wanted to try it out using the crystal.
am contemplating a developement bord using an 18f43k22 in the TQF package, just for testing code but want to get this project done (still waiting on LED switches) so I can make a pcb pattern then order boards.
my list today is to figure out why the second perf board won't work then build a CONST array for binary to compare one port against another (portc=%11100011 then compare against port b =%11100010) not the same..
 
regarding the update
I am using the SE version 2.2.1.8 this is free
will the updated subscription version be a better choice? The subscription version is dated 11/30/2019
 
Stick with the free one. You're not gonna need the advanced version, ever.

Mike
 
Looks like I need to update Swordfish! I noticed the new version a couple weeks ago but didn't install it. Now to remember where my key info is.....
 
I've seen swordfish take hours for LCD to start up
A slight exaggeration me thinks!! I would imagine if the OSC setting affects the delays you could end up with 8 Mhz but running at 500Khz (default )
I' have played with swordfish (free version ) It's definitely better than Oshonsoft… ( I know that's what you kinda said Burt!! Sorry )
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top