Always_Confused_Sudent
Junior Member level 3

Okay, this is my first program ever for a microcontroller , it's supposed to increment the digit that will be displayed on each interrupt,
interrupt source is RB4-RB7.
RA0-RA3 , RB0-RB2 are connected to the 7-segment display,
can anyone check if this is correct and tell me his opinion about the code in general ?
interrupt source is RB4-RB7.
RA0-RA3 , RB0-RB2 are connected to the 7-segment display,
can anyone check if this is correct and tell me his opinion about the code in general ?
Code:
Processor 16f84A
#include "p16f84a.inc"
__config _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
temp equ 0x0c
temp1 equ 0x0d
org 0x00
goto Main
org 0x04
BCF INTCON,0
banksel PORTA
MOVF temp1,0
addwf PCL,1
MOVLW b'01000000' ; zero
goto display
MOVLW b'01111001' ; one
goto display
MOVLW b'00100100' ; two
goto display
MOVLW b'00110000' ; three
goto display
MOVLW b'00011001' ; four
goto display
MOVLW b'00010010' ;five
goto display
MOVLW b'00000010' ;six
goto display
MOVLW b'01111000' ;seven
goto display
MOVLW b'00000000' ;eight
goto display
MOVLW b'00011000' ;nine
goto display
MOVLW 0x00
MOVWF temp1
RETFIE
;;;;;;;;;;;;;;;;;;;;;;;;;;;
display
banksel PORTA
MOVWF temp
MOVLW b'00001111'
ANDWF temp,0
MOVWF PORTA
SWAPF temp,0
ANDLW b'00001111'
MOVWF PORTB
INCF temp1
INCF temp1
RETFIE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Main
banksel TRISA
CLRF TRISA
banksel TRISB
MOVLW b'11110000'
MOVWF TRISB
banksel INTCON
MOVLW 0x88
MOVWF INTCON
MOVWF temp
loop ;;;i added this loop to show myself how interrupt works
DECFSZ temp
goto loop
goto loop
END