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.

long delay on power up

Status
Not open for further replies.

jerryd

New Member
Electro Tech forum,

I have my first microcontroller project up and working.

It's a simple "blink a couple of LEDs" circuit using a
16F88 pic and Mikrobasic Pro. I use the internal 4MHZ
oscillator and when I download the hex file and run
the program it all works except when I apply the 5
volts there is a long delay(15 seconds) before the
programs starts to execute.

I have a reset switch on the MCLR pin but I don't use it.

What am I missing here?

jerryd
 
You need to set the OSCCON = %01110110 0x72 for 8 mhz 0x62 for 4 mhz
 
I had this same thing happen. The PIC in question has both a High Freq built-in osc and a built-in 32KHz RC osc . It was coming up running in the 32Khz mode by default, and later, my start-up routine switched the mode to HF. I had a software delay of a few millisec in the start-up routine ahead of where the oscillator was switched over. The C compiler dutifuly created the delay as though the clock was 4Mhz, but it was actually running at 32kHz, so the delay took a very long time. Simply putting the oscillator initialization near the beginning of the Start-up routine cured it...
 
I did some code a week ago using the timer0 I wasn't thinking about the oscillator starting up at 32 khz because the data sheet said reset it would be set at 4mhz the funny thing was that timer0 was running at 32khz.

I went to get my kids at school came back and the led was on if a button was pressed and the time0 was to set the blink time it was

20 minutes on 20 off it should of been 2 seconds on and off LOL
 
I had some strange delayed startups like that once. Turned out I had accidently forgotten to disable LVP. The floating LVP programming pin caused much strangeness and delayed startups.
 
Electro Tech forum,

be80be: I did have "OSCCON = %01100001 in my program
but as Mikeml said I had to move it before a 100ms pause.

futx: I had already disabled LVP.

It all works now but I'll probably be back.

Thanks for all the replies,
jerryd
 
Yep it's always good to do your initialization first some code can take a long time to run at 32khz delays are one when figured at mhz
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top