I am working on a bootloader for MPC5748G microcontroller. I am facing issues with Flash Read/Write operations after making a jump to our Application from Bootloader. Except for Flash Read/Write operations, rest of the application works as expected.
Given below is the section of bootloader code that makes jump to the application -
void PIT_CH0_DeInit(void)
{
INTC.PSR[226].R = 0x0000; // PIT0 IRQ disabled
PIT.TIMER[0].TCTRL.B.TIE = 0; // Timer interrupt disable
PIT.TIMER[0].TCTRL.B.TEN = 0; // stop Timer
}
void Jump_To_Application(void)
{
UINT32 i;
UINT16 BootHeader = 0;
BootHeader = (*(UINT16*)0x00FA8000);
// Read Upper Byte of Boot Header only. Upper Byte should be 0x005A.
if(BootHeader == 0x005A)
{
SuspendAllInterrupts();
PIT_CH0_DeInit();
// Similarly other used peripherals are deinitialized
//some delay
for(i = 0; I < 10000000; i++)
asm("nop");
asm("e_lis %r12,0x0100");
asm("e_or2i %r12,0x0000");
asm("mtlr %r12");
asm("se_blrl");
}
}
Bootloader makes use of SSD flash drivers. I have following questions -
- Do the flash drivers use any of the controller peripherals which I need to de-initialize before making a jump to application?
- Application code makes use of STM_0 Channel 0 during Flash Read/Write operations. I had a doubt that STM_0 Ch0 interrupt is not getting serviced from the application. I have tried to de-initialize STM_0 Channel 0 from bootloader as below. But this does not help.
STM_0_CCR0 = 0;
// Some delay
for(STM_i = 0; STM_i < 10000000; STM_i++)
asm("nop");
STM_0.CHANNEL[0].CIR.B.CIF = 1;
STM_0.CR.B.TEN = 0;
INTC.PSR[36].R = 0x0000;
Please advise.
lukaszadrapa