为什么一个简单的延迟例程会产生错误 116



>我有一个非常简单的延迟例程来产生大于0.5秒的延迟;这个想法是使用TMR2,PR2和PIC12F683;但它会产生错误116

DELAY MACRO
BANKSEL T2CON
MOVLW 0x76  ; put register w=118
MOVWF T2CON ; T2CON=W=1110111 Start TMR2 and set Postsacaler to 1110
BANKSEL PR2
MOVLW 0xC8
MOVWF PR2 ; Put PR2 to 200
**Lazo
BANKSEL T2CON
BTFSS T2CON,TOUTPS0 ;when TMR2= PR2 bit 3 (post scaler) is incremented from 1110 to 1111 then jump next instruction and end macro
GOTO Lazo****
endm

Error[116]   C:USERSMUTANTEMPLABXPROJECTSCLAXON.XMACROSDEF.INC 12 : Address label duplicated or different in second pass (Lazo)

知道为什么我在 Lazo 循环中出现此错误吗

当宏被实例化时,它的内容被逐字插入,这就是汇编程序看到的。如果在宏内部定义标签,然后多次调用宏,则会多次定义标签,并且会收到此错误。

宏中的标签必须在宏定义中使用 LOCAL 指令,因此:

DELAY MACRO
LOCAL Lazo
BANKSEL T2CON
MOVLW 0x76  ; put register w=118
MOVWF T2CON ; T2CON=W=1110111 Start TMR2 and set Postsacaler to 1110
BANKSEL PR2
MOVLW 0xC8
MOVWF PR2 ; Put PR2 to 200
Lazo
BANKSEL T2CON
BTFSS T2CON,TOUTPS0 ; when TMR2= PR2 bit 3 (post scaler) is 
; incremented from 1110 to 1111 then jump 
; next instruction and end macro
GOTO Lazo
ENDM

最新更新