ARM Technical Support Knowledge Articles

SERIAL EXAMPLE IN GETTING STARTED BOOK FAILS

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

I'm trying to use the serial example in the Getting Started and Creating Applications with uVision and the 166/ST10 manual.

The following code:

char putchar (char c)  {                          /*  substitute func for putchar */
  while ((( unsigned char)(tx_in + 1))==tx_out);  /*  buffer full? */
  _atomic_ (0);
  tx_buf [tx_in++] = c;                           /*  put char in buffer */
  _endatomic_ ();
  if (_testbit_ (tx_restart))  {                  /*  if transmits must be restarted */
    S0TIR = 1;                                    /*  enable transmit request */
  }
  return (c);
}

generates the following warnings and errors.

*** WARNING 140 IN LINE 35 OF .SERIAL.C: '_testbit_' undefined; assuming 'extern int _testbit_()'
*** ERROR 185 IN LINE 32 OF .serial.c: atomic #5: out of range

How can I fix this?

ANSWER

Warning 140 indicates that the specified function is undefined. In this case, the _testbit_ function. This was a misprint which should have been _testset_.

Error 185 indicates that the code in the atomic section is more than 4 instructions.

Change the program code for this example function to read as follows:

#pragma disable
static void putchar2 (char c)  {
  tx_buf [tx_in++] = c;                           /*  put the character in the buffer */
  if (_testclear_ (tx_restart))  {                /*  if transmits must be restarted.. */
    S0TIR = 1;                                    /*  enable transmit request */
  }
}

char putchar (char c)  {
  while ((( unsigned char)(tx_in + 1))==tx_out);  /*  buffer full? */
  putchar2 (c);
  return (c);
}

This solves the warning and error that you received.

MORE INFORMATION

SEE ALSO

Article last edited on: 2006-10-24 14:40:37

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