What is an easy way in code to cause ESM Group 2 event to test that the ESM Group 2 handler is working?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
What is an easy way in code to cause ESM Group 2 event to test that the ESM Group 2 handler is working?
I have tried to use the safeTI diagnostics tests to generate an ESM 2 event but no luck. I tried every test available in safeTI for CCMR4. Below is a sample code of one of the tests I tried. Am I doing something wrong here?
SL_CCMR4F_FailInfo failInfoCCMR4F;
retVal = SL_SelfTest_CCMR4F(CCMR4F_SELF_TEST_ERROR_FORCING, TRUE, &failInfoCCMR4F);
This code is the first thing I run inside of main().
Note, I am running code in real time, not debugger mode. I have a simple counter that increments inside the esm handlers and those get sent to terminal for viewing. This interface works, I am able to track esm1 and esm3 events this way.
Hello James,
One easy way to generate ESM Group 2 error is to write a wrong key to RTIWDKEY register, or not feed the watchdog (DWWD) within the time window.
I just tested and ESM2.24 is set. The following is my test code:
1. enable RTI compare0 INT, and set the RTI compare periods as 200ms
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "rti.h"
#include "esm.h"
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
int ctr = 0;
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
_enable_IRQ();
/* Initialize RTI */
rtiInit();
/* Enable RTI compare 0 notification */
rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
/* Start counter */
rtiStartCounter(rtiCOUNTER_BLOCK0);
/* Initialize and start DWD */
dwwdInit(Generate_NMI, 4095, Size_100_Percent);
dwdCounterEnable();
/* DWD is serviced in the RTI interrupt*/
/* Delay */
while(ctr < 5);
/* Stop Servicing DWD */
rtiDisableNotification(rtiNOTIFICATION_COMPARE0);
while(1);
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
void rtiNotification(uint32 notification)
{
ctr++;
dwdReset();
}
/* USER CODE END */