RTX51 TINY: Running RTX51 Tiny on the Infineon XC878 device
Information in this knowledgebase article applies to:
An application which uses RTX51-Tiny may show sporadic crashes or may not work at all when running on an Infineon XC878.
The Infineon XC878 has an extended stack (see MEXSP register) of 128 bytes where the last code bank number is stored when a LCALL or ACALL is executed. On the other hand, the instructions RET and RETI retrieve the last code bank from this extended stack and decrement the MEXSP. RTX51-Tiny is not designed to make use of this extended stack. RTX51-Tiny uses the following instruction sequence to jump to tasks:
PUSH LowAddress PUSH HighAddress RET
This sequence screws up the extended stack management because there is no LCALL prior to the RET. Since the 128 byte extended stack area is not cleared after a power-up reset, the CPU would jump to a random code bank with a RET instruction that is not preceded by a LCALL instruction.
In most cases, an application will only run on code bank 0. In this case it is sufficient to clear the extended stack so that no random values are retrieved from it. This should be done in the startup code. Since there is no way to directly access the extended stack area, the bank number 0 can to be 'pushed' onto the extended stack with a LCALL instruction. The following code shows one way how to do this:
; Initialize extended Stack. This is absolutely necessary when RTX Tiny is used MOV R0,#XSTACKLEN - 1 ; size of extended stack area XSTACK_LOOP: LCALL XSTACK1 ; dummy call to next instruction to push the ; current bank 0 onto the extended stack XSTACK1: POP ACC ; remove return address from normal stack POP ACC DJNZ R0,XSTACK_LOOP
The attached example project contains a modified START_XC87x.A51 module which clears the extended stack. Please note that clearing the extended stack would not be sufficient if the application needs to switch to a different code bank at any time. This would be the case when ROM functions are called.
Request the files attached to this knowledgebase article.
Last Reviewed: Thursday, June 6, 2013
of your data.