SPC5748G STM freeze Problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SPC5748G STM freeze Problem

1,130 次查看
cskwon
Contributor I

hello everyone

This is a different project from the one I asked this morning.

Timer calculation using STM,

If the variable counted in STM Interrupt is read as extern, STM Interrupt stops.

(Timer_Test++; value stops in Interrupt Routine below)

Includes STM initialization code and interrupt code. Am I setting something wrong?

 

Best regards

 

(Initialize Code)

void Clock_STM_Initialize(void)
{
	   /* Initialize clock gate*/

	    CLOCK_SYS_Init(g_clockManConfigsArr,   CLOCK_MANAGER_CONFIG_CNT,
	                   g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
	    CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
	    /* Initialize and configure pins */
	    //Init_Pins();
	    /* Initialize STM */
	    STM_DRV_Init(INST_STM1, &stm1_InitConfig0);
	    /* Compute the number of ticks from microseconds */
	    STM_DRV_ComputeTicksByUs(INST_STM1, 1000U, &ticks);
	    /* Initialize channel 0 */
	    stm1_ChnConfig0.compareValue = ticks;
	    STM_DRV_InitChannel(INST_STM1, &stm1_ChnConfig0);
	    /* Enable Interrupt for STM0 channel 0 */
	    INT_SYS_EnableIRQ(STM0_Ch0_IRQn);
	    /* Start running the common timer counter */
	    STM_DRV_StartTimer(INST_STM1);
}

 

(Interrupt Code)

void STM0_Ch0_IRQHandler(void)
  {

	  /* Clear channel interrupt flag */
      STM_DRV_ClearStatusFlags(INST_STM1, stm1_ChnConfig0.channel);
      /* Toggle Led to check period */
   //   PINS_DRV_TogglePins(PTG, LED1_PIN_MASK);
      /* Increase the number of ticks in compare register to create a periodic for next event */
      STM_DRV_IncrementTicks(INST_STM1, stm1_ChnConfig0.channel, ticks);
      Timer_Test++;

      if(WiFi_Message_Timer_Flag == 1)
      {
    	  WiFi_Message_Send_timer++;
    	  if(WiFi_Message_Send_timer >= WiFi_Message_Send_Period)
    	  {
    		  WiFi_Message_Send_timer = 0;
    		  WiFi_Message_Send_Flag = 1;
    	  }
      }
      else
      {
		  WiFi_Message_Send_timer = 0;
		  WiFi_Message_Send_Flag = 0;
      }


  }

 

0 项奖励
回复
1 回复

1,120 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

code looks normal, probably comes from demo code. Extern variable should not be an issue.
Maybe just compare value update comes late and next compare happens after STM counter rollovers.
If stopping code in debugger, set STM FRZ bit to stop counter too (e.g. modify stm component for that).

BR, Petr

0 项奖励
回复