We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
With efficiency in mind, the compiler deviates from the standard here. Solution:
https://developer.arm.com/documentation/101655/0961/Cx51-User-s-Guide/Appendix/F--Hints--Tips--and-Techniques/Problems-Using-printf