Hi I'm fairly new to microcontroller programming but am picking things up relatively quickly. Unfortunately I haven't been able to figure this problem out regarding the power source I use to run the programmed PIC16F84A. I use a serial programmer to program the pic offline before putting it into my breadboard circuit.
For right now I'm just testing outputs using LED's while I'm learning programming. If I connect up 3 AA batteries (~3.5V) in series to power the pic, the program goes through the loops without any problem and starts over at the end like it's supposed to. However adding a 4th AA battery (~4.7V) the program will start over halfway through.
I'm really stumped on this. Please let me know if you think of anything that could be causing this problem. BTW I don't fully understand the WDT but have found clearing it in the program makes things run better for me.
Thanks in advance for your help
Here's the little program I'm running:
;***Constants
STATUS equ 0x03
TRISB equ 0x86
PORTB equ 0x06
COUNT1 equ 0x08
;***Port Setup
bsf STATUS,5 ;Bank1
movlw 0x00
movwf TRISB ;PortB all outputs
bcf STATUS,5 ;Bank0
;***Start of Program
Start clrwdt
bcf STATUS,0 ;Clear Carry Flag
movlw 0x01
movwf PORTB
call Delay
;***LED Sequence
CountUp clrwdt
btfsc PORTB,7 ;Flash LED's once seq is done
goto Blink1
rlf PORTB,1
call Delay
goto CountUp
;***Flash LEDs
Blink1 clrwdt
movlw 0x00 ;Turn Off LEDs
movwf PORTB
call Delay
movlw 0xFF ;Program Start over at this point
movwf PORTB ;with 4 batteries but contines fine if 3
call Delay
movlw 0x00 ;Turn Off LEDs
movwf PORTB
call Delay
movlw 0xFF ;Turn On LEDs
movwf PORTB
call Delay
;
;More flashing
;
;
;***I have a little more sequence stuff after this but it never runs.
;***unless i remove the 4th AA battery.
;
goto Start
For right now I'm just testing outputs using LED's while I'm learning programming. If I connect up 3 AA batteries (~3.5V) in series to power the pic, the program goes through the loops without any problem and starts over at the end like it's supposed to. However adding a 4th AA battery (~4.7V) the program will start over halfway through.
I'm really stumped on this. Please let me know if you think of anything that could be causing this problem. BTW I don't fully understand the WDT but have found clearing it in the program makes things run better for me.
Thanks in advance for your help
Here's the little program I'm running:
;***Constants
STATUS equ 0x03
TRISB equ 0x86
PORTB equ 0x06
COUNT1 equ 0x08
;***Port Setup
bsf STATUS,5 ;Bank1
movlw 0x00
movwf TRISB ;PortB all outputs
bcf STATUS,5 ;Bank0
;***Start of Program
Start clrwdt
bcf STATUS,0 ;Clear Carry Flag
movlw 0x01
movwf PORTB
call Delay
;***LED Sequence
CountUp clrwdt
btfsc PORTB,7 ;Flash LED's once seq is done
goto Blink1
rlf PORTB,1
call Delay
goto CountUp
;***Flash LEDs
Blink1 clrwdt
movlw 0x00 ;Turn Off LEDs
movwf PORTB
call Delay
movlw 0xFF ;Program Start over at this point
movwf PORTB ;with 4 batteries but contines fine if 3
call Delay
movlw 0x00 ;Turn Off LEDs
movwf PORTB
call Delay
movlw 0xFF ;Turn On LEDs
movwf PORTB
call Delay
;
;More flashing
;
;
;***I have a little more sequence stuff after this but it never runs.
;***unless i remove the 4th AA battery.
;
goto Start