This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Multi-tasking...

I want to read a character input from the keyboard so I used..

getchar();

The problem is, I want to be able to continue on with my program if user does not enter any character from the keyboard. The solution I have in mind is to do multi-tasking, but I am not sure if 8051 supports it. Also, I know that in C++, there is a function called..

peek();

This will return out of its function if a key is not pressed. So I want to know if C has a function similar to this...

thanks
Tommy

Parents
  • Just write your own character fetch routine (http://www.8051.com has a multitude of suggestions). If you are not doing something complicated, do not consider an RTOS it will - if character fetch is your only problem - give you more headaches than writing a character fetch routine. You can write the routine to return 0 or ff if no char is available, if all 256 codes are possible make a global flag character_present set by character fetch, reset by "main"

    Have fun,

    Erik

Reply
  • Just write your own character fetch routine (http://www.8051.com has a multitude of suggestions). If you are not doing something complicated, do not consider an RTOS it will - if character fetch is your only problem - give you more headaches than writing a character fetch routine. You can write the routine to return 0 or ff if no char is available, if all 256 codes are possible make a global flag character_present set by character fetch, reset by "main"

    Have fun,

    Erik

Children
No data