Keil Logo

µVISION DEBUGGER: PROBLEMS SIMULATING THE SERIAL INTERFACE


Information in this article applies to:

  • C251 Version 3.20
  • C51 Version 6.20
  • µVision Version 2.20

QUESTION

I'm using the µVision Debugger to simulate my serial interface and I'm having problems receiving characters. My function to receive characters appears as follows:

char getch (void)  {
  while (!RI);
  RI = 0;
  return (SBUF);
}

This function always returns a value of zero when I run it in the simulator. It seems to work on the real hardware so why does the µVision simulator fail?

ANSWER

This function is potentially unsafe because it resets the RI bit before reading the SBUF register. In the real hardware, this code may work most of the time. However, the RI bit is being cleared too early. The µVision debugger always returns 0 in such cases. You should change the function to the following:

char getch (void)  {
  char ch;

  while (!RI);
  ch = SBUF;
  RI = 0;
  return (ch);
}

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Friday, September 3, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.