1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

Get a character from serial port

Discussion in 'Microcontrollers' started by RodgerE1, Dec 20, 2010.

  1. RodgerE1

    RodgerE1 New Member

    Likes Received:
    Trophy Points:
    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.


    Any suggestions on an alternative way to do this?

    Any help, is appreciated, thank you.
  2. wuxin999

    wuxin999 New Member

    Likes Received:
    Trophy Points:
    you can set a conditon,if the condition is ture,jump out the loop,if not ,go on run the getkey command.
    use while() or if(),set the times of getkey command.
: 8051, keil

Share This Page