TMDX570LC43HDK: System Reset from privileged FreeRTOS task causing hang in sciInit function

Part Number: TMDX570LC43HDK

Tool/software:

Hello,

I have created a FreeRTOS privileged task and in the task , all it does is sleeps for 1 second and after 10 seconds it resets. When I run from the Code Composer in debug mode, I see it works for the first Reset but the next Reset, it gets stuck in sciInit function.

What I found was that, after first Reset, the reset source is set to DEBUG_RESET, so it is going through _memInit_(), _coreEnableEventBusExport_(), systemInit(), _coreEnableIrqVicOffset_() ... etc. The next Reset source is set to NO_RESET, so it is not going through the normal initialization process, which is probably the cause. Could you please let me know what is the best way to reset the system, do I need to follow any specific procedure for reset. Note that, if I do reset the board with Power On Reset switch, it only runs once, the reset gets stuck in the sciInit like 

Here is the code, if needed, I can provide the entire project.

void vResetTask(void)
{
volatile int32_t count = 10;

for (;;)
{
sciInitPrint("Sleeping ...");
if (--count < 0)
{
vTaskDelay(pdMS_TO_TICKS(100));
systemREG1->SYSECR = (1U) << 15;
}
else
{
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
}

int main(void)
{
gioInit();
sciInit();

sciInitPrint("\r\n ----- MAIN-----!!!!!!\r\n");

//Errata - Device#56
uint32_t esmekr = esmREG->EKR;
if (esmekr != 0)
esmREG->EKR = 0x5;
esmekr = esmREG->EKR; //Read back to check

xTaskCreate(vResetTask, "Reset System", 256, NULL, (1 | portPRIVILEGE_BIT), NULL);

vTaskStartScheduler();

while(1);

return 0;
}

Thanks for your support.

Regards,

Sarbeswar