Chrysostomos
New Member
Hey,
I am using PIC16F84A micro controller. I am trying to program a 7 segment display to count until 9. The code in assembly I wrote for that is as follows: Its not working and i dont know why. Can anyone help me pls ? its quite simple example
#include P16F84A.INC
__config _XT_OSC & _WDT_OFF & _PWRTE_ON
DELAY_COUNT1 EQU H'21'
DELAY_COUNT2 EQU H'22'
DELAY_COUNT3 EQU H'23'
COUNT EQU H'24'
ORG h'0'
clrf PORTA ;clear output latches
clrf PORTB ;
bsf STATUS,5 ;select bank1
movlw B'00000000'
movwf TRISB
movlw D'0' ; setting count value as 9
movwf COUNT
bcf STATUS,5 ;select bank 0
loop
movlw B'11111111'
movlw COUNT
call counter
goto loop
counter
incf COUNT,0
call conversion
movwf PORTB
return
delay
;initialise delay counters
movlw H'FF'
movwf DELAY_COUNT1
movlw H'FF'
movwf DELAY_COUNT2
movlw H'05'
movwf DELAY_COUNT3
delay_loop
decfsz DELAY_COUNT1,F ; inner most loop
goto delay_loop ; decrements and loops until delay_count1=0
decfsz DELAY_COUNT2,F ; middle loop
goto delay_loop
decfsz DELAY_COUNT3,F ; outer loop
goto delay_loop
return
conversion
addwf PCL
retlw B'01000001' ;0
retlw B'11110011' ;1
retlw B'00100101' ;2
retlw B'00001101' ;3
retlw B'00011011' ;4
retlw B'10001001' ;5
retlw B'10000001' ;6
retlw B'01011101' ;7
retlw B'00000001' ;8
retlw B'00011000' ;9
end
I am using PIC16F84A micro controller. I am trying to program a 7 segment display to count until 9. The code in assembly I wrote for that is as follows: Its not working and i dont know why. Can anyone help me pls ? its quite simple example
#include P16F84A.INC
__config _XT_OSC & _WDT_OFF & _PWRTE_ON
DELAY_COUNT1 EQU H'21'
DELAY_COUNT2 EQU H'22'
DELAY_COUNT3 EQU H'23'
COUNT EQU H'24'
ORG h'0'
clrf PORTA ;clear output latches
clrf PORTB ;
bsf STATUS,5 ;select bank1
movlw B'00000000'
movwf TRISB
movlw D'0' ; setting count value as 9
movwf COUNT
bcf STATUS,5 ;select bank 0
loop
movlw B'11111111'
movlw COUNT
call counter
goto loop
counter
incf COUNT,0
call conversion
movwf PORTB
return
delay
;initialise delay counters
movlw H'FF'
movwf DELAY_COUNT1
movlw H'FF'
movwf DELAY_COUNT2
movlw H'05'
movwf DELAY_COUNT3
delay_loop
decfsz DELAY_COUNT1,F ; inner most loop
goto delay_loop ; decrements and loops until delay_count1=0
decfsz DELAY_COUNT2,F ; middle loop
goto delay_loop
decfsz DELAY_COUNT3,F ; outer loop
goto delay_loop
return
conversion
addwf PCL
retlw B'01000001' ;0
retlw B'11110011' ;1
retlw B'00100101' ;2
retlw B'00001101' ;3
retlw B'00011011' ;4
retlw B'10001001' ;5
retlw B'10000001' ;6
retlw B'01011101' ;7
retlw B'00000001' ;8
retlw B'00011000' ;9
end