This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem displaying a variable

Good day,

to test my C source code file I added the following lines:

printf(“ r1 = %d\n", r1); 

Display in the terminal program: “r1 = 514”

printf("key = %x = %c = %d\n", key, key, key); 

Display in the terminal program: “key = 101 = □ = 0”

printf("r1 = %x = %c = %d\n", r1, r1,r1); 

Display in the terminal program: “r1 = 202 = □ = 0”

I declared the variables as follows:

unsigned char data r1 = 0; → 0-255

bit data key = 0; → 0 or 1

Unfortunately I can't explain why the values out of the range (0-255, 0-1) are displayed?

Compiler: Keil-C version V5.38.0.0

Kind Regards

Juergen