While using the simulator, the values of i in the serial window are shifted by left 8 bits.
#include "stdlib.h" #include "stdio.h" #include "reg51.h" void main (void) { unsigned char i; SCON = 0x50; TMOD |= 0x20; TH1 = 221; TR1 = 1; TI = 1; for (i = 0; i < 8; i++) { printf("%x\n", i); } }
Failing could be a reasonable outcome. When you go back to school, take a course in good manners and proper etiquette.
"GOOGLE DID NOT HAVE INFO"
Toggle that Caps Lock key. C is a case-sensitive language. You'll never get a program to compile if it's written in all caps.
Yes, Google did have the info. So did Wikipedia for that matter, showing how BCD format. Knowing that, one can easily craft the code to print its value.
You certainly don't appear to be competent to pass!
PLEASE
ANSWER NOW!
THANK YOU
Hi Xiong Ling,
If you would like an answer, please consider the following code fragment first:
printf("Don't shout, ask precisely, be polite\n");
Then we might be able to help you.
I NEED ANSWER NOW!
GOOGLE DID NOT HAVE INFO
HELP PLEASE
How old are you?
Screaming like a pig and constantly repeating your question as if your tail was on fire isn't exactly a good way to get help!
In this case, it will only give you the tip to GOOGLE...
School work should be done by you, not by us!
YOU HELP PLEASE
I TRY "%2.2X" and "%2.2BCD" BUT NOT RIGHT!
HOW IS BCD STORED? WHAT YOU MEAN?
YOU HAVE ANSWER NOW?
Shouting isn't going to help you!
Have you tried thinking about how you might use the available facilities to do this?
Think about how a BCD value is stored - you could extract each digit, and print it; or you could convert the value to a number, and then just print that...
WHERE IS ANSWER
HELP PLEASE NOW!
ANYONE KNOW ANSWER PLEASE
I WAIT FOR ANSWER NOW
HELLO PLEASE
I NEED TO PRINT NUMEBR IN BCD WITH PRINTF
BUT MANUAL DOES NOT GIVE EXAMPLE
HOW TO DO?
"It was a question posted in a Keil forum about a Keil specific implementation. I searched the forum first and didn't find any pertinent posts."
But you obviously hadn't read the manual.
"Why even have a forum? Let's just let Andy reply to all posts with Please read the manual."
When a post asks a question that is clearly and specifically addressed in the Manual, surely "Please read the manual" is the entirely appropriate response. I even gave you the specific page, and pointed you to the specific section.
Surely, the purpose of the forum is to answer those questions that go beyond what is already spelled-out in the manuals?
B and b Neil Kurzman They are not ANSI C. They are Keil specific additional.
Thank you, Captain Obvious. Maybe you should also let everyone know that we have landed on the moon.
They are not ANSI C. They are Keil specific additional.
View all questions in Keil forum