首页 > 解决方案 > 如何避免 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 位值。

标签: ccompiler-warningspicmicrochipxc8

解决方案


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


推荐阅读