I need to start a function and it must run continiosly until i press a key. I have tested it using "getchar()", but it doesn't work, becuase i need to press something to continue running the software. So, I think that i should start a process that only waits for a key to be pressed, but i don't know how to do this. What can i do?
rs-232, i forgot to write it before....
In that case, a simple approach might just poll the UARTs RI bit.
"rs-232, i forgot to write it before...."
This is fundamental!
So, in fact, your 8051 knows nothing about keypresses at all!
All your 8051 knows is when a character has arrived at its serial port - it doesn't know and cannot tell whether that came from a PC, or any other device that could send characters over RS232, nor what caused the character to be sent.
As Christoph hints, the RI bit indicates when the 8051's UART has received a character. For details of how this works, you need to study the so-called "bible" for the 8051:
Chapter 1 - 80C51 Family Architecture: www.semiconductors.philips.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.semiconductors.philips.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.semiconductors.philips.com/.../80C51_FAM_HARDWARE_1.pdf
Here are some other introductory & reference materials: http://www.keil.com/books/8051books.asp www.8052.com/books.phtml www.8052.com/tutorial.phtml