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 PORTB ; Set all Port B pins to logic 0 BSF RB3,RB5 ; Bank 1 command comes next STATUS RP0 set CLRF PORTB ; sel all Port B pins as outputs BCF RB3,RB5 ; Bank 0 command comes next STATUS RP0 clear
CLRF ptrlo ; start offset pointers at zero CLRF ptrhi
CLRW MOVWF PORTB ; Port B to zero CALL DELAY ; "freeze" LEDs
MOVLW 0xFF MOVWF PORTB ; Port B ones CALL DELAY ; "freeze" LEDs
repeat: INCF ptrlo ; next loc MOVF ptrlo,W CALL tab1 ;;*REMoving this, one sees 0x00 0xFF (counting) ; otherwise,one sees only repeating 0x00 0xFF MOVWF PORTB ; Port B from W CALL DELAY ; "freeze" LEDs GOTO repeat ; ---------------------------------------------- DELAY MOVWF sW ; MOVF STATUS,W ; MOVWF sSTATUS CLRF COUNT1 CLRF COUNT2 MOVLW d'45' ; 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
Note the CALL tab1 does not work. Why?