Please bear with me, I am new to Embedded c.
We are using a ADUC848 Microcontroller that has an 8051 based core. We are using Keil uVision 3.
What we need to do is send a #TST# string out from the Microcontroller, which we are accomplishing using a printf("!&#TST#&\n"); command.
The Microcontroller is connected to a PC via USB, but a PC isn't always used, so the embedded software will run with or without it.
If the computer sees the #TST# string it will send a signal to the Microcontroller, telling it to start running a test.
If the Microcontroller does not see the signal from the computer, it will send the #TST# string a couple more times.
If it still doesn't see it, the Microcontroller will begin running the test.
We want to do this in about 5 seconds.
The embedded C software has already been written and it works fine, but i'm trying to add this functionality, because when they are using a PC, we want to make sure that they see each other properly.
My problem:
I've been trying to use the Getkey command to get the character from the computer. It works, but the problem is the getkey command halts execution and won't start again until it gets a key
Basically, what i'm asking is, is there anyway we can have the getkey run for 5 seconds, if it doesn't find anything, then it will just continue.
OR
Any suggestions on an alternative way to do this?
Any help, is appreciated, thank you.
Don't use that function at all - but access the underlaying registers directly by polling/interrupt in conjunction with the a timeout.
That is the documented behaviour!
If you don't want that behaviour then, as Tamir says, don't use that function!
I understand now it's the documented behavior, so what do I do? I didn't understand Tamir's reply. Dumb it down for me please.
All of my programming experience is in Visual Basic.
Thanks,
Rodger
Here are some books on embedded programming: http://www.keil.com/books
Well, it's pretty basic embedded stuff so, rather than dumb it down, it really needs you to wise up on the embedded front.
See the booklist above for starters...
You are absolutely right I need to learn, the problem is, i'm running out of time. I'll check out the books, thank you!!
There are lots (!) of documentation about how to send bytes of data on the serial port, or how to receive bytes of data on the serial port.
The information isn't weeks away. It is only hours away. You could have started from scratch and picked up the relevant info, implemented it and tested it this weekend, and have lots of time to spare for R&R.
A nice interrupt-driven UART receiver with a ring buffer would work very well. If the ring buffer is empty, then you don't need to spend time waiting for characters to arrive. Just come back at a later time and check if there is data in the buffer.
Or even just a couple of clicks away: http://www.keil.com/support/
Thank you! I'm researching.
http://www.keil.com/condb
With hours, I didn't just meant the time to locate the information, but the total time to read the documentation and understand the concept enough to make use of it. Serial communication is one of the best documented topics in the embedded world.
Has this thread run out of time?
See: http://www.keil.com/forum/18814/