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.

18f43K20 timing woes

Status
Not open for further replies.
I didnt see his code until after i posted. I assumed (thats stupid), Mr eb would know if SF needed start up code put before main etc, not knowing the ins and out of basic i looked at the datasheet. All i spotted was the fact he had written to a bit you normally read.

Also nothing about the WD etc, i like to set my fuses exactly as i want them and all the start up stuff, often i cut and paste as i use alot of the same settings. The other thing i some times do is how clock output on a pin, so i can double check the speed on a scope.
 
The 18f1220 is 32 khz clock i timed it the lcd code would start in 2 hours. I didnt think it was working i left it on came back about 3 hours later to work on it agin
and the text was showing up. So i timed it i reset it and sit there till it came on.
A led blinky was about 20 minutes.
 
The 18f1220 is 32 khz clock i timed it the lcd code would start in 2 hours. I didnt think it was working i left it on came back about 3 hours later to work on it agin
and the text was showing up. So i timed it i reset it and sit there till it came on.
A led blinky was about 20 minutes.
That seems real slow for a led blinky! I run a ARM cortex M3 chip at 32kHZ for low power reasons, its happy to blink a led every 600mS
 
Your delay is for 8mhz and the uC is running at 32 khz big time change there.
I even tested that too I changed the clock= to 32khz it work fine with a blinky
The Lcd had a bunch modules.
But if you use a module for osccon the chip works right from the start.
 
Most the sil labs boards i use have a custom LCD and the chips have on board controllers. Make a huge difference power wise.
 
YES I have used the IntOSC.bas BUT I needed to place directly after the clock setting.
I never got around to trying the IntOSC.bas until Tumbleweed suggested it, Thanks. The testing blinking of the Led is one of my first steps in writing code and now I learned that I need to put the INCLUDE files ( IntOSC.bas first) which makes sense.
Now I need to figure out how to get the porta.6 & 7 s an output.(INTOSCIO) IS SUPPOSED TO DO IT BUT ?
I have the HLVD module that when I have it in operation by itself it works just fine BUT when I have portC 0-7 in the code portC.6 led comes on by itself? Maybe the change I made with the clock will be the remedy??
 
YES I have used the IntOSC.bas BUT I needed to place directly after the clock setting.
I never got around to trying the IntOSC.bas until Tumbleweed suggested it, Thanks. The testing blinking of the Led is one of my first steps in writing code and now I learned that I need to put the INCLUDE files ( IntOSC.bas first) which makes sense.
Now I need to figure out how to get the porta.6 & 7 s an output.(INTOSCIO) IS SUPPOSED TO DO IT BUT ?
I have the HLVD module that when I have it in operation by itself it works just fine BUT when I have portC 0-7 in the code portC.6 led comes on by itself? Maybe the change I made with the clock will be the remedy??
Go back and set ALL fuses correctly, make sure you have the watch dog etc all set up or off. Dont take short cuts, learn to set the chip up completely, if you want to learn you will find one thing holds true.... All short cuts lead the long way around.

Read the data sheet on the port your looking at using, read it all and follow any links to other parts if needed. Learning data sheets is a PITA, but they are the key to pics, also MC has some of the best written and most comprehensive data sheets, also glance over errata for the chip your using, you would be amazed what turns up in those.

If you want to learn properly i dont mind helping, SF i cant help much with, but the general datasheet stuff i can help with.
 
I think his chip is running at 1 mhz so a delay takes 8 times as long where as my chip was taking 250 times as long.
 
Well if he put the set up in main then it wont reach his OSCON setting for a while, he does set it for 8MHz but apparently in main.

Still no idea why he attempted to set the stable flag, never tried it myself :D

But at least he is looking at dta sheets
 
He just needs to add his IntOSC.bas it should be first as Jerry said it set's the clock using the clock line of of code to what he has. 8 16 32 whatever.
 
How do you set the PLL with it?
 
The confiure word fuses
Then the inosc.bas thats what i use i read the data sheet and set the osccon line in it and include as a module
 
How do you set the PLL with it?
When using intosc.bas if you set the 'clock=' to a freq that requires the PLL (ie 32 or 64MHz) it should automatically turn it on for you.

If you run across a device that doesn't seem to work right, just post a note and I'll fix it. I didn't test all of them...
 
Now I need to figure out how to get the porta.6 & 7 s an output.(INTOSCIO) IS SUPPOSED TO DO IT BUT ?
intosc.bas will set the config so that PortA.6 and PortA.7 are IO pins (if your device supports it).
For the 18F43K20 it'll set 'config FOSC = INTIO67', so you shouldn't have to do anything else... you should be able to use them as you normally would.

Of course, they default to inputs like all the other pins so if you want outputs set them that way.
 
YES I have used the IntOSC.bas BUT I needed to place directly after the clock setting.
I never got around to trying the IntOSC.bas until Tumbleweed suggested it, Thanks. The testing blinking of the Led is one of my first steps in writing code and now I learned that I need to put the INCLUDE files ( IntOSC.bas first) which makes sense.
Now I need to figure out how to get the porta.6 & 7 s an output.(INTOSCIO) IS SUPPOSED TO DO IT BUT ?
I have the HLVD module that when I have it in operation by itself it works just fine BUT when I have portC 0-7 in the code portC.6 led comes on by itself? Maybe the change I made with the clock will be the remedy??
So what does the DS say about port C? especially what to do with it

Tumbleweed beat me to it, Mr Deb read the data sheet FFS! You wont learn by not reading. This is basic stuff. First page of port C tells you exactly why it isnt working

It says...in a BOX
Note:
On a Power-on Reset, these pins are con-
figured as digital inputs.

C.6 is also what pin? read the DS on that pin and you realize why sometimes it might already be output
 
Last edited:
Swordfish generally isolated you from needing to get too deep into the data sheet. For routine stuff, various include modules take care of the details - in this case, getting the oscillator running at the correct speed.

MrDEB left out an include file he's used in every other program he's "created." Explaining why it needs to go first is about as deep an understanding as you can hope for. Pointing him to the data sheet when he thinks that SetAllDigital should have something to do with clock speed is less than helpful.
 
Even so i would expect reading the DS to flag in your mind you need something set, how its sets is kind of not the point. SF might do it for you but the sheet tells you it needs doing. Now both you and tumble weed go slap yourselves for helping. These are mistakes i should be making having never used the software, no way should someone who has no end of projects under the belt not know the very basics of there tools.
 
LG, everything you're pointing out makes complete sense.

Obviously, you've forgotten whose thread you're posting in. Keep it up and you'll end up like Jon.
 
....should....know....the....basics....

Absolutely. But for someone who doesn't and can't understand why setting the state on an input port pin makes no sense, it ain't gonna happen.

Swordfish does insulate the user from a lot of the details. I know many people here who would say you have to know every page of the data sheet, that you must learn programming starting with assembler and it's supposed to be a long painful process, but it doesn't have to be. For routine stuff, if you pick the right include modules in Swordfish, you don't need to know the nitty gritty details. It will help if you do, but it's not essential.

If you're trying to use special features of the micro or do something unusual, then you may need to break out the data sheet, understand the functions of all the resisters and so on.
 
the clock is running fine after I put the IntOSC.bas IN AFTER THE CLOCK
inserted back in the into67 to configure the A.6 and A.7 as I/O pins but when the PIR2 TRIPS, THE PORTC.6 & 7 come on as well but not supposed to. I can live without the HLVD module in the code.
basic=code
DEVICE = 18F43k20 ' Tell the compiler what chip we are using
CLOCK = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
INCLUDE "IntOSC.bas"
INCLUDE "SetDigitalIO.bas"
INCLUDE "Utils.bas"
CONFIG MCLRE = OFF
CONFIG fOSC = INTIO67 ' Internal oscillator, IO on pins 6 and 7
CONFIG boren = off
INCLUDE "SetDigitalIO.bas"
INCLUDE "Utils.bas"


SUB HLVD()
HLVDCON =%00011100 'see section 22.0 for setup and table 26-4 for voltage setting
'set to 4 volts in this case 11100 = 3.1 volts
PIR2.bits(2) = 0
IF PIR2.bits(2) = 1 THEN 'check HLVD interrupt

Green1= 0 'LED = ON
PIR2.bits(2) = 0 'clear HVLD interrupt

ELSE
Green1= 1 'LED = OFF
END IF

TOGGLE (Pwr_on)
DELAYMS(50)
END SUB
[/code/QUOTE]
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top