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.
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); } }
WHERE IS ANSWER
HELP PLEASE 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...
YOU HELP PLEASE
I TRY "%2.2X" and "%2.2BCD" BUT NOT RIGHT!
HOW IS BCD STORED? WHAT YOU MEAN?
YOU HAVE ANSWER NOW?
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!
I NEED ANSWER NOW!
GOOGLE DID NOT HAVE INFO
HELP PLEASE
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.
PLEASE
ANSWER NOW!
THANK YOU
You certainly don't appear to be competent to pass!
"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.
Failing could be a reasonable outcome. When you go back to school, take a course in good manners and proper etiquette.
CANNOT FIND INFORMATON ON GOOGLE!
GIVE URL OF INFOMATION NOW
I jusr read the thraad (it is Monday morning here) and I see one word in all your posts which is "NOW"
so, In your opininion, everybody that has a paid job and occsionally visit this forum, should immediately drop what they are doing to earn their pay and for free take care of the fact that you have no idea of even the most basic concepts.
Ok, here is a suggestion
post whithout using capitals a short synopsis of what the BCD format is and how YOU propose to code the conversion so we know that you have, at least, done some work yourself and maybe, just maybe someone will forget the way you have behaved so far in this thread.
Erik
What search strings did you try?
"WANT ANSER BCD PRINTING PLEASE NOW"
THIS IS CODE MY FRIEND GAVE ME
HE SAID HE GOT IT FROM GOOGLE AND IT WORKS BUT NOT CORRECTLEY
int printbcd(int value) { printf("%x",binerytobcd(value)); } int binerytobcd(int binery) { int frpol; /* framing p?? */ int bcd; /* working sum */ for( frpol = 0 ; frpol < 7 ; frpol = frpol + 1) { if (binery<2) /* is binery a binery number*/ bcd = bcd + 1; /* change bcd to add it */ binery = binery - 2; /* do next number */ } return ( bcd % 255 ); /* get rid of last bit */ }
I TRY AND I DO NOT SEE CORRECT ANSWER
CHECK CODE AND SAY WHAT IS WRONG
"CHECK CODE AND SAY WHAT IS WRONG"
First, why do you and your friend think it is not correct? What have you observed?
"... WORKS BUT NOT CORRECTLEY"
How can something WORK and not be CORRECT?