Hi everyone. I've been working on a program below which is a modification of Henrik's look up table program. I know if you had a PIC with an eight bit wide output you could store the output words in the lookup table and then drive a seven segment display directly as Henrik explained.
So I thought I'd try and load a lookup table to blink an LED (D0) 3 times using a for-next-loop (I've never used a for-next-loop before). It works except after three cycles it doesn't stop. I read up that after the loop has finished it then moves on down to the next instruction, so I've added STOP / END. IF i = 4 then STOP. None of these work and when any of these lines are added the program only cycles once.
The only thing I can think of is that the 12F683 doesn't support LOOKUP tables.
Any ideas please? Dave
ANSEL = %00000000 'disable analog select so ports work as digital i/o
CMCON0 = %00000111 'Disable analog comparators
TRISIO = %11001111 'Set GPIO.4&5 to input
GPIO = %00000000 ' set all outputs low
i VAR BYTE
START
Main:
pause 500 'pause 500 mili-secs
For i = 1 to 3 ' loop count variable (value i) also number of times to loop.
LOOKUP i, [ 223, 223, 223] ,GPIO '223 = %11011111 D0 switches on (GPIO.4)
Pause 500 'pause 500 mili-secs
LOW GPIO.4 ' DO switches off
Next i ' loop again. ONE is added to count i and prog jumps to FOR
Bookmarks