How to input ASCII values coming from serial. E.g if 8-bit ASCII code '80' of alphabet P, or 8-bit ASCII code '49' of digit 1 is recieved at serial port, how do I input this ASCII.
"how do I input this ASCII?"
char received_character; received_character = SBUF;
thanks.. But I want to ask one more thing... When I recieve 49, do I recieve 1 or the ASCII 49. I mean to say that if I want to compare the value recieved how can I do that,.. char recieved_char; recieved_char='SBUF'; if(recieved_char==49) { . . } "OR" char recieved_char; recieved_char = SBUF; if(recieved_char==1) { . . } OR char recieved_char; recieved_char = SBUF; if(recieved_char=='1') { . . }
"When I recieve 49, do I recieve 1 or the ASCII 49." Computers store numbers in binary. The UART receives data in binary. It is just a representational issue. 00110001 binary equals 49 decimal equals 31 hex equals 61 octal equals 1 ASCII etc Maybe you should read an introductory text of some sort. Alternatively, as I understand that reading is unfashionable these days, you could experiment using the debugger.
What is a debugger and how is it used?
Stefan said: "Maybe you should read an introductory text of some sort. Alternatively, as I understand that reading is unfashionable these days, you could experiment using the debugger." Fatima replied: "What is a debugger and how is it used?" Oh well, it looks like you're stuck with just doing some reading, then! :-0 I suggest that you start by reading the uVision Getting Started Guide - and working through the example Projects in it
"It is just a representational issue." Absolutely. Maybe this will explain it further for you: http://www.8052.com/forum/read.phtml?id=96256
"What is a debugger and how is it used?" Sorry, I should probably have said simulator rather than debugger. Run your code in the simulator, you will be able to view the value of variables to see what is happening. If you don't know what the simulator is then I'm afraid you are going to have to resort to reading the manuals.
What is a debugger and how is it used? I have heard about teaching kids to swim by throwing them into the deep end of the pool. Are you trying to learn to program the '51 by the same method? Erik