; Simple Example Program PROCESSOR 16F873 __CONFIG 0x3FF6 INCLUDE ; This is the contents of APP2.INC SerialSetup EQU 0x0F03 SerialTransmit EQU 0x0F14 SerialReceive EQU 0x0F0E Hexout EQU 0xF1A Hexout0 EQU 0xF1D Delay EQU 0xF23 FlashWrite EQU 0xFBF FlashRead EQU 0xFCA ; warning routine uses ; RAM 20 GetHexByte EQU 0xFB0 #define LED PORTB,0 cblock 0x20 i ; byte variable j k endc org 0x0 goto main org 0x5 main: MOVLW HIGH SerialSetup ; Set up RS232 MOVWF PCLATH CALL SerialSetup CLRF PCLATH BSF STATUS,RP0 ; Make LED an output BCF LED ; Turn on timer MOVLW 0xDF MOVWF OPTION_REG BCF STATUS,RP0 CLRF k loop: BCF LED ; toggle LED with delay CALL dly BSF LED CALL dly incf k,f ; bump up K counter movlw k movwf FSR MOVLW HIGH Hexout ; output K MOVWF PCLATH MOVLW k CALL Hexout movlw ' ' ; and a space call SerialTransmit CLRF PCLATH GOTO loop ; Do a lengthy delay dly: movlw 0x80 movwf j dlyl: call dlyx DECFSZ j,F GOTO dlyl RETURN dlyx: CLRF i dly1: CLRF TMR0 nop nop tdly: BTFSS TMR0,7 GOTO tdly DECFSZ i,F GOTO dly1 RETURN END