Hello all,
we did change the memoryInit function generated by HalcoGen (don't aks why ;-) )
The generated function is the following
/** @fn void memoryInit(uint32 ram)
* @brief Memory Initialization Driver
*
* This function is called to perform Memory initialization of selected RAM's.
*/
/* SourceId : SELFTEST_SourceId_002 */
/* DesignId : SELFTEST_DesignId_004 */
/* Requirements : HL_SR396 */
void memoryInit(uint32 ram)
{
/* USER CODE BEGIN (6) */
/* USER CODE END */
/* Enable Memory Hardware Initialization */
systemREG1->MINITGCR = 0xAU;
/* Enable Memory Hardware Initialization for selected RAM's */
systemREG1->MSINENA = ram;
/* Wait until Memory Hardware Initialization complete */
/*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
while((systemREG1->MSTCGSTAT & 0x00000100U) != 0x00000100U)
{
Timer_Delay_sw(1000); // THIS LINE IS ADDED FROM US!!!
}/* Wait */
/* Disable Memory Hardware Initialization */
systemREG1->MINITGCR = 0x5U;
/* USER CODE BEGIN (7) */
/* USER CODE END */
}
The Timer_delay_sw function is the following:
void Timer_delay_sw(TIME_T countNops)
{
for(; countNops > 0U; countNops--)
{
__asm__("nop");
}
}
With this function call included, the processor got somehow "confused". Depending on the project I have strange behavior like a reset (PC jumping to 0) after the memoryInit is executed or I got stuck in some self test endless loop. Does anybody have a hint why such a change could have such an influence? I also have my own theory: The systemREG1->MSINENA = ram does delete the stack hence the return address of the memoryInit function has to be stored in some register. Maybe after calling the Timer_delay_sw function this return address does get changed?
Any other ideas would be very appreciated.
Matthias