C语言 如何避免 xc8 编译器中的警告 1352?



我在microchip的xc8编译器中使用了这个宏:

#define Unlock()  
do { 
asm("BANKSEL PPSLOCK");   
asm("MOVLB   PPSLOCK");   
asm("MOVLW   0x55");      
asm("MOVWF   PPSLOCK");   
asm("MOVLW   0xAA");      
asm("MOVWF   PPSLOCK");   
asm("BCF     PPSLOCK,0"); 
} while (0)

这是数据手册中提到的用于解锁外设引脚选择的特殊序列。
并始终收到以下警告:

../_main.c:437: warning: (1352) truncation of operand value (0xea0) to 8 bits
../_main.c:437: warning: (1352) truncation of operand value (0xea0) to 8 bits
../_main.c:440: warning: (1352) truncation of operand value (0xea0) to 4 bits

0xEA0PPSLOCK寄存器的地址,但我没有看到任何可以截断的东西,我只是在 8 位 SFR 中写入 8 位值。

MOVWF运算只占用地址操作数的 7 位,而你给它 12 位。这就是为什么您必须事先选择银行的原因。

最新更新