|
ANTENNA TEST CODE Antenna LED test code for the Mainboard (PIC16F876) The main part of the code at "Start" performs the following function: Antenna Left LED on This has the effect of alternately turning on and off the Antenna LED's A sample delay routine is looked at in the Sample Code section. 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 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 ;reselect bank 0 Start bsf AntL ;turn on left LED bcf AntR ;turn off right LED movlw .100 ;100*10mS=1S call LongDelay ;wait for 1 second bcf AntL ;turn off left LED bsf AntR ;turn on right LED movlw .100 ;100*10mS=1S call LongDelay ;wait for 1 second goto Start ;loop forever ;***** Delay Routines from 12 uS to 255 Sec ;***** Very Long Delay 1 Sec to 255 Sec, value in w on entry, 1 tick = 1 Sec VLongDelay movwf VLDelay waitvldelay movlw .100 call LongDelay decfsz VLDelay,F goto waitvldelay return ;***** Long Delay 10 mS to 2.55 Sec, value in w on entry, 1 tick = 10 mS LongDelay movwf LDelay waitldelay movlw .10 call MedDelay decfsz LDelay,F goto waitldelay return ;***** Medium Delay 1 mS to 255 mSec, value in w on entry, 1 tick = 1 mS MedDelay movwf MDelay waitmdelay movlw .83 call ShortDelay decfsz MDelay,F goto waitmdelay return ;***** Short Delay 12 uS to 3 mSec, value in w on entry, 1 tick = 12 uS ShortDelay movwf SDelay WaitSDF nop nop nop nop nop nop nop nop nop nop decfsz SDelay,F goto WaitSDF Return ;************************** ;*** Config word *** ;************************** __CONFIG h'3FFF' & _LVP_OFF & _BODEN_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF end
|