Hello
I‘m programming my S32k146/144 board with FTM function and I found a ridiculous issue. I used a data array to record the free running FTM chanle counter. The data stream indicated that the counter occasionally updates to a random number instead of following its normal cyclic way. I tested all FTM chanles with almost the same code on both S32K144 and S32K146,the error perfectly repeated. Beacause the testing code is very simple, I am quite confused. I post the code and result here. Is there anyone could tell me what happed.
void IOC_Init(void)
{
/* Configure clock to FTM0 module and Enable */
PCC->PCCn[PCC_FTM0_INDEX] |= PCC_PCCn_PCS(1) | PCC_PCCn_CGC_MASK;
/* Enable registers updating from write buffers, Enable FTM0,2 Module */
FTM0->MODE |= FTM_MODE_WPDIS_MASK;
FTM0->MODE |= FTM_MODE_FTMEN_MASK;
/* Clear SC Register,close clock,Set FScaler to 4,Filter 2 */
FTM0->SC = FTM_SC_PS(2);
/* Clear main counter */
FTM0->CNTIN = 0;
FTM0->MOD = 0xFFFF;
/* Clock selection and enable*/
FTM0->SC |= FTM_SC_CLKS(3);
}
#include "main.h"
unsigned int IOC_CH0[256],j=0;
void Delay(unsigned int count)
{
unsigned int i;
for (i=0;i<count;i++){;}
}
int main(void)
{
/* Initialization: */
WDOG_disable(); /* Disable WDOG */
SOSC_init_16MHz(); /* Initialize system oscillator for 16 MHz xtal */
SPLL_init_160MHz(); /* Initialize SPLL to 160 MHz with 8 MHz SOSC */
NormalRUNmode_80MHz(); /* Init clocks: 80 MHz sysclk & core, 40 MHz bus, 20 MHz flash */
IOC_CH0[0] = 0;
IOC_Init();
/* Infinite for: */
for (;;)/* Loop: if a msg is received, transmit a msg */
{
if (j>255){j = 0;}
IOC_CH0[j] = FTM0->CNT;
Delay(0x1FF);
j++;
}
}
FTM_error.PNG