RTI Instruction to start off Scheduler

nobody wrote on Friday, April 27, 2007:

I am trying to run FreeRTOS on a HCS12X processor and when it comes to the point where the Scheduler should start there is an RTI instruction. However, the PC is then set to an instruction in the void PE_low_level_init(void) function. Then the function finishes its work and nothing happens, the PC points at an BGND instruction… I have no idea how to fix it.


nobody wrote on Friday, April 27, 2007:

The code goes as follows:

/* Restore the context of the first task. */

/* Simulate the end of an interrupt to start the scheduler off. */
__asm( "rti" );

Without knowing the details of the HCS port in particular, the first line should setup the stack pointer such that the RTI instruction causes the program counter to be loaded with the address of the first instruction of the task about to execute.

You should be able to step through the portRESTORE_CONTEXT() code to see this happen.  When you step through the code, check that the registers are loaded with their expected values as setup by pxPortInitialiseStack() in port.c.  By the looks of it the X register should contain 0xffee and the Y 0xddcc.  If this is not the case then something is wrong before portRESTORE_CONTEXT() is called.

I presume PE_ functions are processor expert functions.  Have you at any time enabled the processor expert in the project?  If so, unzip a clean version, then when you open the project and you are asked if you want to connect it to the processor expert, select NO.

Another Dave.

nobody wrote on Friday, April 27, 2007:

I don’t have Processor Expert at all, these functions are included in the clean version of FreeRTOS. The big problem is that the port is for MC9S12DP256 and my MCU is MC9S12XDP512 so what I am actually trying is to adapt it. I’ve changed the linker parameter file and the cpu.c file but it is obviously not enough.

I tried stepping through portRESTORE_CONTEXT() and unfortunately the registers don’t have the values you mentioned. Could there be anything in the port files I have to change so that it works properly on my MCU?

rtel wrote on Friday, April 27, 2007:

What are the differences in the architecture between the MC9S12DP256 and MC9S12XDP512?  I’m guessing the 512 just means more flash, but what does the X get you?


nobody wrote on Friday, April 27, 2007:

Yes, 512 is the amount of Flash memory. X probably stands for XGATE, which is a “peripheral co-processor that allows autonomous data transfers between the MCU’s peripherals”, but I don’t use it.