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
0xEA0
是PPSLOCK
寄存器的地址,但我没有看到任何要截断的内容,我只是在 8 位 SFR 中写入 8 位值。
解决方案
该MOVWF
操作只占用地址操作数的 7 位,而您给它 12 位。这就是为什么你必须事先选择银行。
推荐阅读
- git - 每个 repo 分支具有不同分支的 GitModules
- python - 如何减少对 Postgresql db 执行 SQL 查询的 python 脚本的 CPU 使用率
- sql - 从 postgres 中的同一组中选择一个早期和最近的日期
- jquery - 选择多个过滤器后,jQuery toggle() 不起作用
- javascript - JQuery 双滚动 - 边距/对齐问题
- spring-boot - 使用 Grails 3 设置 Camunda
- python - pytesseract 努力识别带有字体编号和 7 段数字的干净黑白图片(python)
- python - 调整散点图 matplotlib
- php - PHPMailer 只是在发送电子邮件时挂起
- r - R c.Date() 引发警告调用 'structure(NULL, *)' 已弃用