;****************************************************** ;* LED_table.ASM ;* PORTC外接LED,查表輸出,共四筆資料 ;****************************************************** list p=16F877 #include ; VAL_US equ .249 ; 1ms delay 給定初值 VAL_MS equ .250 ; 呼叫1ms Delay之次數 VAL_S equ .4 count equ 0x20 ; 1ms delay 變數位址 count_ms equ 0x21 ; 呼叫1ms Delay之變數位址. count_s equ 0x22 count_tb equ 0x23 ; ;****** 程式開始 ********************* org 0x00 ; reset vector nop ; Reserve for MPLAB-ICD initial: clrw clrf PCLATH banksel TRISC ; Select to bank1 clrf TRISC ; PORTC = Output banksel PORTC ; Select to bank0 clrf PORTC ; Clear PORTC incf PORTC,f movlw 0x00 movwf count_tb start: bsf PCLATH,2 pagesel Table movf count_tb,w call Table bcf PCLATH,2 movwf PORTC pagesel delay_s call delay_s incf count_tb,f pagesel start btfss count_tb,2 goto start goto initial ; ;-------- s delay routine ---------- delay_s: movlw VAL_S movwf count_s loop_s call delay_250ms decfsz count_s,f goto loop_s return ; ;-------- 250 ms delay routine ---------- delay_250ms: movlw VAL_MS movwf count_ms loop_ms call delay_1ms decfsz count_ms,f goto loop_ms return ; ;-------- 1 ms delay routine ----------- delay_1ms: nop movlw VAL_US movwf count dec_loop nop decfsz count,f goto dec_loop return ; org 0x1C00 Table: addwf PCL,f retlw 0x3C retlw 0xC3 retlw 0x00 retlw 0xFF retlw 0xAA end