;****************************************************** ;* LED_INC1.ASM ;* PORTC外接LED,輸出值由0開始每隔一段Delay時間加1 ;****************************************************** list p=16F877 #include ; VAL_US equ .249 ; 1ms delay 給定初值 VAL_MS equ .250 ; 呼叫1ms Delay之次數 count equ 0x20 ; 1ms delay 變數位址 count_ms equ 0x21 ; 呼叫1ms Delay之變數位址. ; ;****** 程式開始 ********************* org 0x00 ; reset vector nop ; Reserve for MPLAB-ICD initial: banksel TRISC ; Select to bank1 clrf TRISC ; PORTC = Output banksel PORTC ; Select to bank0 clrf PORTC ; Clear PORTC start: incf PORTC,f ; PORTC = PORTC + 1 call delay_250ms ; Call delay routine goto start ; ;-------- 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 ; end