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 -
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.
Hi Shantanu,
answer to your first question is no. The SSD flash driver does not touch other peripherals.
I'm not sure if I can understand the second question. What can you see exactly? If the read-while-write error is caused by core access, machine check exception should be triggered because that access is terminated by bus error. So, you should relatively easily find which piece of code caused the problem.
If STM interrupts are not triggered then make sure that:
- interrupt flag is set
- interrupt is enabled in STM module
- priority register is configured appropriately in INTC
- MSR[EE] is set
If you are missing only some interrupts, it can be caused by low priority or lack of performance.
Regards,
Lukas