Program:
LIST p=P16F648A #include P16F648A.inc ; Was P16F628A __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _HS_OSC & _LVP_OFF & _MCLRE_OFF & _BOREN_OFF __IDLOCS 0x0001
; VARIABLES ptrlo EQU 0x20 ; table pointer ptrhi EQU 0x21 COUNT1 EQU 0x22 ; delay counter COUNT2 EQU 0x23 COUNT3 EQU 0x24 sSTATUS EQU 0x25 sW EQU 0x26 ; ORG 0x0000 GOTO start GOTO start GOTO start GOTO start ORG 0x0010 start: ;** setup I/O ; All pins have 10K in series with an LED to GND except OSC pins (and GND)
CLRF 6 ; Set all Port B pins to logic 0 BSF 3,5 ; Bank 1 command comes next STATUS RP0 set CLRF 6 ; sel all Port B pins as outputs BCF 3,5 ; Bank 0 command comes next STATUS RP0 clear
CLRF ptrlo CLRF ptrhi
CLRW MOVWF 6 ; Port B to zero CALL DELAY ; "freeze" LEDs
MOVLW 0xFF MOVWF 6 ; Port B ones CALL DELAY ; "freeze" LEDs setup: MOVLW Low(tab1) ADDWF ptrlo,W ; add pointer to W MOVLW High(tab1) BTFSC STATUS,C INCF PCLATH,F ; W=1 CALL tab1 ;;*REMoving this, one sees 0x00 0xFF 0x01 repeating ; RETurns here ;; otherwise, LEDs show 0x00 0xFF repeating MOVWF 6 ; Port B from W CALL DELAY ; "freeze" LEDs GOTO start
repeat: ;;*This part disabled for now.. INCF ptrlo ; next loc ; BTFSC STATUS,C ; INCF ptrhi MOVF ptrlo,W ; CALL tab1 ;;*REMoving this, one sees W counting ;; otherwise, LEDs show 0x00 0xFF 0x00 0xFF 0x00 etc MOVWF 6 ; Port B from W CALL DELAY ; "freeze" LEDs GOTO repeat
; ---------------------------------------------- DELAY MOVWF sW ; MOVF STATUS,W ; MOVWF sSTATUS CLRF COUNT1 CLRF COUNT2 MOVLW d'43' ; fudge for about 4 Sec delay MOVWF COUNT3 LUPINR DECFSZ COUNT1 GOTO LUPINR DECFSZ COUNT2 GOTO LUPINR DECFSZ COUNT3 GOTO LUPINR DEXIT:; MOVF sSTATUS,W ; MOVWF STATUS MOVF sW,W RETURN ; ---------------------------------------------- sine ORG 0x0100 tab1: ;; RETLW 0x01 ; [0] t=0.7500 r=0.0000 ADDWF PCL,F RETLW 0x15 ; [1] t=0.7539 r=0.0240 RETLW 0x14 ; [2] t=0.7578 r=0.0964 RETLW 0x13 ; [3] t=0.7617 r=0.2173 RETLW 0x12 ; [4] t=0.7656 r=0.3865 RETLW 0x02 ; [5] t=0.7695 r=0.6040
WHAT in all heck is happening??