我有一个非常简单的延迟例程,可以产生大于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:\USERS\MUTANTE\MPLABXPROJECTS\CLAXON.X\MACROSDEF.INC 12 : Address label duplicated or different in second pass (Lazo)
任何想法我为什么会在Lazo循环中出现此错误
答案 0 :(得分:1)
实例化宏时,其内容将逐字插入,这就是汇编器看到的内容。如果您在宏内部定义标签,然后多次调用该宏,则标签会被定义多次,这时将出现此错误。
宏中的标签必须在宏定义内部使用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