|
SWITCH TEST PROGRAM Switch test program for Mainboard (PIC16F876) The main part of the code at "Start" performs the following function: Turn both LED's off The routine is in an endless loop. This has the effect of turning on the LED's when the switch is pressed. Notes of interest:
The Code:
list p=16f876 #include "P16F876.inc" ;Define ports so we can use them by name #define AntL PORTA,2 ;OUTPUT #define AntR PORTA,3 ;OUTPUT #define Sw PORTC,1 ;INPUT cblock 20h VLDelay, LDelay, MDelay, SDelay ;variables for delay routines endc org 0 goto init ;jump over interrupt vectors org 10 init bsf STATUS, RP0 bcf STATUS, RP1 ;select bank 1 movlw b'11110011' movwf TRISA ;RA2,RA3 set as outputs movlw b'00000110' ;set porta i/o's as digital movwf ADCON1 bcf STATUS, RP0 ;select bank 0 Start bcf AntL bcf AntR loop btfsc Sw goto Start bsf AntL bsf AntR goto loop ;************************** ;*** Config word *** ;************************** __CONFIG h'3FFF' & _LVP_OFF & _BODEN_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF end
|