Keil Logo

RTX51: Bank Switch Mode 1 causes sporadic Runtime-Errors

Information in this article applies to:

  • RTX51 Full Version 5
  • RTX51 Full Version 7


An application that is using code banking in banking mode 1 or banking mode 4 might cause sporadic problems with RTX51 Full when the system interrupt is triggered within the bank switching code.


The RTXCONF.A51 file contains a restore bank function that compares the current bank with the new bank. Since the bank switching code of banking mode 1 and mode 4 no longer disables the interrupt system, a potential run-time error might cause crashes of the application.

This occurs when the RTX51 system interrupt is called exactly on the update of the B_CURRENTBANK value, but before external hardware I/O lines are updated.


Change the code for ?RTX_SWITCHBANK in the file RTXCONF.A51 to:

JMP  ?B_RESTORE_BANK   ; new entry in L51_BANK that restores an old bank
;; -- the old code is no longer required
;;                         ; Check if bank switching required
;;                         CJNE A, ?B_CURRENTBANK, SWITCH
;;                         RET
;;                         ; Extract the Banknumber
;;SWITCH:                  ANL  A, #?B_MASK
;;                         MOV  B, #?B_FACTOR
;;                         DIV  AB
;;                         MOV  R7, A
;;                         JMP  _SWITCHBANK    ; Switchbank-Routine in L51_BANK


The problem only exists in combination with L51_BANK.A51 configuration file version 2 and will be solved in future RTX51 revisions.

If you are using the L51_BANK.A51 Version 1.4 (which was part of the C51 Version 5) the run-time error does not occur, since this code disables the interrupt system during bank switching.


  • Ax51 User's Guide, Chapter 9, Code Banking


Last Reviewed: Thursday, February 25, 2021

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.