Keil Logo


Information in this article applies to:

  • RTX51 Version 5.10b


We are using RTX51 and we have noticed that it accesses P2 directly for some reason. Due to the nature of our particular custom 8051 we need P2 for I/O. Why is RTX51 accessing P2 and can it be configured to not do it?


RTX51 accesses P2 when you start using reentrant functions with fast tasks. It uses P2 to access different pages of PDATA where fast task reentrant stacks are located.

It is not possible to disable this operation of RTX51.


The only option is to avoid using reentrant functions. If you have functions that are called from more than one task then there are a couple of things you can try (depending on your project):

  1. Protect the function from being called while it is executing. You can do this with semaphores for example. You will then need to disable the linker warnings using the DW directive.
  2. Make multiple copies of the function and use one for each task. While this can make maintaining the code harder, there is a method you can use to write a single function and automatically generate mutliple copies. For example:
    #define func func1
    #include "FUNC.C"
    #undef func
    #define func func2
    #include "FUNC.C
    // FILE FUNC.C
    unsigned char func(unsigned char x)
      return x + 1;

    Include TWOFUNCS.C in your project, not FUNC.C. The function 'func' ends up as two identical copies called 'func1' and 'func2'.


Refer to pages 118-120 of the RTX51 User's Guide (04.98) for more information on the XDATA/PDATA memory usage of RTX51.


Last Reviewed: Tuesday, July 19, 2005

Did this article provide the answer you needed?
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.