Search code examples
chexwarningsiarfirmware

C - Warning [pe069] integer conversion resulted in truncation


I know that this question has been asked several times, anyway I didn't find and answer to my specific case:

IAR Embedded Workbench returs this warning on compiling:

"Warning [pe069] integer conversion resulted in truncation" on the line:

SPI2_Tx(DVC_CTR2,       0x1000);

where DVC_CTR2 is

#define DVC_CTR2                0x0F

and SPI2_Tx definition is

static void SPI2_Tx(uint8_t pAddress, uint8_t pData)

How can I resolve this warning? Thanks in advance!


Solution

  • This is because you cannot transmit a two-byte value through SPI routine that transmits a single byte.

    You should be able to do it with two separate calls:

    SPI2_Tx(DVC_CTR2, 0x10);
    SPI2_Tx(DVC_CTR2, 0x00);
    

    If you must transmit 16 bits at once, look up a different routine that takes uint16_t.