#include "Project.inc" #define Delay.Returned Delay.flag,3 Delay_ovr udata_ovr ;May do some overlay Delay.Counter res 1 global Delay.flag, Delay.start, Delay.Wait flag_ovr udata_ovr Delay.flag res 1 ;using bit 3 ------------------------------ ;延时w*50mius ------------------------------ Delay.start banksel Delay.Counter ;2Cycles 1 movwf Delay.Counter ;1Cycle 1 banksel OPTION_REG ;2Cycles 1 ;setting prescaler to 1:2,选择8M内部晶振 clrf OPTION_REG ;1Cycles 1 banksel TMR0 ;2Cycles 1 movlw 0xEA ;1Cycles 1 ;0x100 - 0x32 (50u) + 0x06 (static offset) + 0x07(Interrupt) + 0x0F (n first cycle)= 0xEA to compenste static Offsets movwf TMR0 ;1Cycles 1 bcf INTCON,T0IF ;this and below: dont't care timer already started bsf INTCON,T0IE banksel Delay.flag bcf Delay.Returned return -------------------------------- ;等待延时结束 -------------------------------- Delay.Wait banksel Delay.flag btfss Delay.Returned goto $-1 ;at least 2 Cycles 1 bcf INTCON,T0IE ;1Cycle 1 return END