简体   繁体   中英

How to avoid the warning 1352 in xc8 compiler?

I used this macro in the xc8 compiler from microchip:

#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)

This is a special sequence mentioned in the datasheet to unlock the peripherial pin selection.
And always get these warnings:

../_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 is the adress of the PPSLOCK register, but I didn't see anything to truncate I just write 8 Bit values in an 8 Bit SFR.

The MOVWF operation takes just 7 bits of the address operand, and you give it 12 bits. That's why you have to select the bank beforehand.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM