Hello,
I'm stuck with a problem occuring while trying to run the SelfTestControler SelfCheck on the TMS570LS04x Eval Board. I'm using HalcoGen and want to do the STCSelfCheck like described in the technical reference.
The following things I'm doing in the HalcoGen generated Code:
1. I choose the Selftest frequency
2. I select the amount of intervals
3. I choose the timeout frequency
4. I wait 16 VBUS clock cycles
5. I'm enabling the STC SelfCheck
6. I'm sending the CPU to Idle Mode in order to start the Check
thats this code:
void stcSelfCheck(void)
{
/* USER CODE BEGIN (8) */
/* USER CODE END */
volatile uint32 i = 0U;
/* Run a diagnostic check on the CPU self-test controller */
/* First set up the STC clock divider as STC is only supported up to 90MHz */
/* STC clock is now normal mode CPU clock frequency/2 = 180MHz/2 */
systemREG2->STCCLKDIV = 0x01000000U;
/* Select one test interval, restart self-test next time, 0x00010001 */
stcREG->STCGCR0 = 0x00010001U;
/* Enable comparator self-check and stuck-at-0 fault insertion in CPU, 0x1A */
stcREG->STCSCSCR = 0x1AU; <---------- I dont understand why this step is necessary
/* Maximum time-out period */
stcREG->STCTPR = 0xFFFFFFFFU;
/* wait for 16 VBUS clock cycles at least, based on HCLK to VCLK ratio */
/*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "Wait for few clock cycles (Value of i not used)" */
/*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "Wait for few clock cycles (Value of i not used)" */
for (i=0U; i<(16U + (16U * 0U)); i++){ /* Wait */ }
/* Enable self-test */
stcREG->STCGCR1 = 0xAU;
/* USER CODE BEGIN (9) */
/* USER CODE END */
/* Idle the CPU so that the self-test can start */
_gotoCPUIdle_();
What should happen now is that "at the end of each interval, the 128 bit MISR value (reflected in registers CPUx_CURMISR[3:0])" gets shifted into the SelfTestControler and is then compared with a "golden" (whatever that means) value in the ROM. After that the Controler resets and starts the program from beginning.
Sadly the MISR Register Value is complete zeros in my case and in the end I'm always ending up having errors diagnosed from both CPUs in my control registers. My main code looks like this:
if((stcREG->STCGSTAT & 0x00000001U) == 0x00000000U){ //if STC SelfTest not completed (STCGSTAT Bit1 low)
stcSelfCheck(); //Start STC SelfTest
}
else if(((stcREG->STCGSTAT) & 0x00000002U) == 0x00000002U){ // STC SelfTest completed and failed (STCGSTAT Bit2 high)
if(((stcREG->STCFSTAT) & 0x00000004U) == 0x00000004U){ //TimeOut Error happened
sciSend(scilinREG, 25, (unsigned char *)"An TimoOut Error occured.");
}
if(((stcREG->STCFSTAT) & 0x00000002U) == 0x00000002U){ //CPU2 Error happened
sciSend(scilinREG, 23, (unsigned char *)" CPU2 created an error.");
}
if(((stcREG->STCFSTAT) & 0x00000001U) == 0x00000001U){ //CPU1 Error happened
sciSend(scilinREG, 23, (unsigned char *)" CPU1 created an error.");
}
}
I'm new to microcontroler coding and would appreciate your help.
thanks,
Jonathan