ARM Technical Support Knowledge Articles

PROBLEMS SIMULATING THE SERIAL INTERFACE

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

I'm using the uVision 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 uVision 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 uVision 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

Article last edited on: 2004-09-03 13:59:57

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential