Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
I am using SDCC for pic 18f252.
It give me a warning I can not resolve:
Executing: "C:\Program Files\SDCC\bin\sdcc.exe" SD.c -c -mpic16 -p18F252 -I"Z:\GPS_Tracker\GPS_courseTracker\GPS_Embarque\Softs\TRIMBLE_decoder"
SD.c:165: warning 94: comparison is always true due to limited range of data
typeSD.c:166: warning 126: unreachable code
This is an extract of my code:
char spi_write(char d)
SSPBUF = d;
while (spi_write(0xFF) != 0xFF);
the warning concern "while (spi_write(0xFF) != 0xFF);"
I don't understand because I compare spi_write(0xFF) which return a char, with 0xFF which is a char...?
note: - SSPBUF is the SPI register : 8bits
- BF is a bit saying the 8bits are received
Can anybody say me what I do wrong?
Thanks a lot.
I did not test it, but I suspect this has to do with integer promotion of the operands during comparison: The literal 0xFF is the integer value 255, which is not representable using a (signed) char.
Try using unsigned char as the return type of spi_write(), or cast the result to unsigned char in the comparison, or change the literal to -1.
OK, thank you, it works with unsigned