PDA

View Full Version : 7 second delay on startup



Russ Kincaid
- 20th March 2006, 20:13
I wrote a short program for 16F627A, using internal oscillator, WDT and power up timers disabled, MCLR is an input. low voltage programming enabled. The program runs OK but 7 seconds after power is applied. I don't want that delay, how do I get rid of it? This is the .ASM file, I don't understand it, but perhaps someone can tell me how there is a delay here.

; PicBasic Pro Compiler Demo, (c) 1998, 2004 microEngineering Labs, Inc. All Rights Reserved.
PM_USED EQU 1

INCLUDE "16F627A.INC"

RAM_START EQU 00020h
RAM_END EQU 0014Fh
RAM_BANKS EQU 00003h
BANK0_START EQU 00020h
BANK0_END EQU 0007Fh
BANK1_START EQU 000A0h
BANK1_END EQU 000EFh
BANK2_START EQU 00120h
BANK2_END EQU 0014Fh
EEPROM_START EQU 02100h
EEPROM_END EQU 0217Fh

R0 EQU RAM_START + 000h
R1 EQU RAM_START + 002h
R2 EQU RAM_START + 004h
R3 EQU RAM_START + 006h
R4 EQU RAM_START + 008h
R5 EQU RAM_START + 00Ah
R6 EQU RAM_START + 00Ch
R7 EQU RAM_START + 00Eh
R8 EQU RAM_START + 010h
FLAGS EQU RAM_START + 012h
GOP EQU RAM_START + 013h
RM1 EQU RAM_START + 014h
RM2 EQU RAM_START + 015h
RR1 EQU RAM_START + 016h
RR2 EQU RAM_START + 017h
; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00012 led var byte
_led EQU RAM_START + 018h
_PORTL EQU PORTB
_PORTH EQU PORTA
_TRISL EQU TRISB
_TRISH EQU TRISA
#define _PORTB_2 PORTB, 002h
#define _PORTB_0 PORTB, 000h
#define _PORTB_1 PORTB, 001h
INCLUDE "FLASHB~1.MAC"
INCLUDE "PBPPIC14.LIB"


; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00013 TRISA = %00000000 'ALL OUTPUTS
MOVE?CB 000h, TRISA

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00014 TRISB = %00000000
MOVE?CB 000h, TRISB

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00015 PORTB = %00000011 'PINS 6 & 7 HIGH, ALL OTHERS LOW
MOVE?CB 003h, PORTB

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00017 FOR LED = 1 TO 5 'FLASH LEDs 5 TIMES
MOVE?CB 001h, _led
LABEL?L L00001
CMPGT?BCL _led, 005h, L00002

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00018 PORTB.2 = 1 'LEDs ON PIN 8
MOVE?CT 001h, _PORTB_2

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00019 PAUSE 150
PAUSE?C 096h

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00020 PORTB.2 = 0
MOVE?CT 000h, _PORTB_2

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00021 PAUSE 150
PAUSE?C 096h

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00022 NEXT LED
NEXT?BCL _led, 001h, L00001
LABEL?L L00002

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00023 FREQOUT 3, 5000, 2500 'SOUND ON PIN 9
FREQOUTPIN?C 003h
FREQOUTTIME?C 01388h
FREQOUT?C 009C4h

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00024 PORTB.0 = 0
MOVE?CT 000h, _PORTB_0

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00025 PORTB.1 = 0 ' TURN OFF POWER
MOVE?CT 000h, _PORTB_1

; C:\PROGRA~1\MECANI~1\MCS\FLASHB~1.PBP 00026 END
END?

END

skimask
- 20th March 2006, 23:30
Check your PCON register setting (see the PIC16F62xA datasheet, section 14.2.8).
You might actually be running at 37khz vs. 4mhz if you are using the internal clock.
By my calculations, it should actually be starting up about 16 seconds after power on if you haven't defined any other oscillator setting (meaning the default setting of 4mhz is used by default). It makes more sense if you've actually 'defined' 8mhz.

Does the whole program run slow or just the start up?

JDG

Darrel Taylor
- 20th March 2006, 23:52
Russ,

Do you have a Pull-Down resistor on the RB4/PGM pin?
<br>

Russ Kincaid
- 21st March 2006, 20:09
JDG: The program runs normal speed once it starts. I re-programmed the PIC (nothing different, as far as I know), but now the delay is gone. I did not specify the clock frequency, it seems that the MeLabs programmer over-rides any PICBASIC commands?

Darrel: The RA4/PGM pin is set as an output and low. Do I need a pull down resistor?

Darrel Taylor
- 21st March 2006, 22:46
Yes, you still need a resistor.

When the LV programming is enabled, the output stage is over-ridden, so the state of the TRIS bit will have no effect.
<br>

skimask
- 23rd March 2006, 01:46
Show us the regular code, not the assembly output.
Why it works now is beyond me. The programmer won't override anything in PBP sends it or anything that PM sends it. The software that drives the programmer might, but definetely not the programmer itself.
In any case, I don't see a 7 second delay in the startup as a config word problem or something like that.
Maybe something in the circuitry just took awhile to charge up or power up and combined with no resistor on RB4 was the problem overall....who knows...
JDG