talhak
New Member
Hello to everyone,
I'm new here and happy to see an active forum about micro-controllers.. I'm working on PIC16F877A.. I've some problems with it.. I'll be happy if someone helps me.. Thanx..
First of all this is my code for "Look-up Table".. It takes the value from 1-9 and show them on LEDs.. I really tried to find my mistake but I couldn't..
I'm new here and happy to see an active forum about micro-controllers.. I'm working on PIC16F877A.. I've some problems with it.. I'll be happy if someone helps me.. Thanx..
First of all this is my code for "Look-up Table".. It takes the value from 1-9 and show them on LEDs.. I really tried to find my mistake but I couldn't..
Code:
list p=16f877a
#include<p16f877a.inc>
__CONFIG H'3FF0'
NUM EQU h'21'
ADDON EQU h'22'
ORG h'00'
GOTO START
INIT:
BSF STATUS,5
CLRF TRISB
BCF STATUS,5
CLRF PORTB
MOVLW h'09'
MOVWF NUM ; it loops 9 times when it is zero, end program.
MOVLW h'00'
MOVWF ADDON ; looking the table; first take 1 and 2, 3, ... ,9
BCF STATUS,2
BCF STATUS,0
RETURN
LOOKTABLE:
MOVF NUM,0
ADDWF PCL,1
RETLW h'01'
RETLW h'02'
RETLW h'03'
RETLW h'04'
RETLW h'05'
RETLW h'06'
RETLW h'07'
RETLW h'08'
RETLW h'09'
SEND:
MOVWF PORTB ; to leds
RETURN
START:
CALL INIT
LOOP:
CALL LOOKTABLE
CALL SEND
INCF ADDON,1
MOVLW h'00'
SUBWF NUM,1
BTFSS STATUS,0
GOTO LOOP
END
Last edited: