I am using Uvision2. For some reasons I still see the negative value when declared a variable as unsigned interger -- According to the compiler, it supposes to be positive number from 0 - 65536. Here is the sample test code I have used:
unsigned int A = 0; while (1) { printf("\n\r Value= %d", A); A++; }
%d is a signed integer conversion specifier. %u is the unsigned version.
As Dan says, the problem here is not the data type of 'A' - it is the way that you're asking printf to interpret it. Out of interest, you might like to try this:
unsigned int A = 0; while (1) { printf("\n\r Unsigned Value= %u", A); printf("\n\r Signed Value= %d", A); A++; }
I got it. Thank you