EXPLANATION OF THE PROGRAM
| _RC_OSC EQU H’3FFF’ _WDT_OFF EQU H’3FFB’ STATUS EQU 03h TRISA EQU 85h PORTA EQU 05h TRISB EQU 86h PORTB EQU 06h __CONFIG _WDT_OFF & _RC_OSC Org 00h Bsf STATUS, 5 Movlw 1Fh Movwf TRISA Movlw 00h Movwf TRISB Bcf STATUS, 5 Start Btfsc PORTA, 0 Call F1 Btfsc PORTA, 1 Call F2 Btfsc PORTA, 2 Call F3 Btfsc PORTA, 3 Call F4 Btfsc PORTA, 4 Call F5 Btfsc PORTA, 5 Call F6 Btfsc PORTA, 6 Call F7 Btfsc PORTA, 7 Call F8 Goto Start F1 Movlw b’11111111’ Movwf PORTB Goto Start F2 Movlw b’10101010’ Movwf PORTB
Goto Start F3 Movlw b’01010101’ Movwf PORTB Goto Start F4 Movlw b’11001100’ Movwf PORTB Goto Start F5 Movlw b’00110011’ Movwf PORTB F6 Movlw b’11110000’ Movwf PORTB F7 Movlw b’00001111’ Movwf PORTB F8 Movlw b’11000111’ Movwf PORTB Goto Start End | ; Resistor, capacitor oscillator memory location address H’3FFF’ ; Watch dog off memory location address ; STATUS memory location address ; TRISA memory location address ; PORTA memory location address ; TRISB memory location address ; PORTB memory location address ; configure the fuses ; memory starts at origin 00h ; go to Bank 1 ; store 1Fh at W register, this mean from Ra0 to Ra4 will become input because 1Fh means 11111 in binary, if I give 1 that will move soon into TRISA I command that the port will become an input
; from W register move it into TRISA ;store 00h at W register (note the previous data stored in W register will be overwrite ) this mean from Rb0 to Rb7 will become output because 00h means 00000000 in binary, if I give 0 that will move soon into TRISB I command that the port will become an output ;From W register move the data into TRISB ;go back into Bank0 ; this is only a variable ;BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 0. why bit 0 because the Ra0 is at the bit 0. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra0 is 1 then got to F1 ; BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 1. why bit 1 because the Ra1 is at the bit 1. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra1 is 1 then got to F2 ; BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 2. why bit 2, because the Ra2 is at the bit 2. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra2 is 1 then got to F3 ; BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 3. why bit 3, because the Ra3 is at the bit 3. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra3 is 1 then got to F4 ; BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 4. why bit 4, because the Ra4 is at the bit 4. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra4 is 1 then got to F5 ; BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 5. why bit 5, because the Ra5 is at the bit 5. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra5 is 1 then got to F6 ; BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 6. why bit 6, because the Ra6 is at the bit 6. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra6 is 1 then got to F7 ; BTSFSC means Bit Test register F, and Skip if it is Clear. Test the PORTA at Bit 7. why bit 7, because the Ra7 is at the bit 7. if the sample get a 0 signal the it escape the instruction but if it is 1 it will continue to the next instruction. ; if the input at ra7 is 1 then got to F8 ; if all input is 0 then repeat the test got to Start again ; if F1 is called then go to the next instruction.
; store this data at W register : from W register move the data into PortB, this instruction will turn ON all the LED :then back to Start ; if F2 is called then go to the next instruction.
; store this data at W register : from W register move the data into PortB, this instruction only 4 LED will turn ON. :then back to Start ; if F3 is called then go to the next instruction.
; store this data at W register : from W register move the data into PortB, this instruction only 4 LED but it is counter part of the above instruction will turn ON. :then back to Start ; if F4 is called then go to the next instruction.
; store this data at W register : from W register move the data into PortB, this instruction only 4 LED will turn ON. :then back to Start ; if F5 is called then go to the next instruction.
; store this data at W register : from W register move the data into PortB, this instruction only 4 LED will turn ON. :then back to Start ; end of the program ;Note: F1 to F8 is not a part of PIC program but this is only a variable |
