Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
flony
Level 1
Level 1
First like received 5 sign-ins First reply posted

I use iLLD  for my developing. In the program I use STM for system timer.I have two problems:

1.This is the initialization of the STM module.

 

void TimerInit(void)
{
  TimerReset();
  ticks = IfxStm_getTicksFromMicroseconds(&MODULE_STM0, 1000);
  ticksStart = IfxStm_get(&MODULE_STM0);
  IfxStm_enableOcdsSuspend(&MODULE_STM0);

  millisecond_counter = 0;
}

 


 In main loop function, I check the timer whether the 1ms is reached and increase the timer millisecond_counter.

 

void TimerUpdate(void)
{
  uint64 ticksNow = 0;

  ticksNow= IfxStm_get(&MODULE_STM0);
  if (ticksNow >= (ticksStart + ticks))
  {
    ticksStart = ticksNow;
    millisecond_counter++;
  }
}

 


 If I do some Flash operation,erase and write(i also call the TimerUpdate() function to get timer),there will be trigger a trap:IfxCpu_Trap_Class_contextManagement() and program stoped. why ?

2.To realize the same function,i used STM's compare.

 

void TimerInit(void)
{
  TimerReset();
  ticks = IfxStm_getTicksFromMicroseconds(&MODULE_STM0, 1000);
  ticksStart = IfxStm_get(&MODULE_STM0);
  IfxStm_enableOcdsSuspend(&MODULE_STM0);

  IfxStm_initCompareConfig(&stmCompareConfig);
  stmCompareConfig.ticks           = ticks;
  IfxStm_initCompare(&MODULE_STM0, &stmCompareConfig);

  millisecond_counter = 0;
}

 


In the TimerUpdate(),I check the compare flag.

 

void TimerUpdate(void)
{
  if (IfxStm_isCompareFlagSet(&MODULE_STM0, stmCompareConfig.comparator))
  {
    IfxStm_clearCompareFlag(&MODULE_STM0, stmCompareConfig.comparator);
    IfxStm_increaseCompare(&MODULE_STM0, stmCompareConfig.comparator, stmCompareConfig.ticks);

    millisecond_counter++;
  }
} 

 


 In the Flash operation, the compare flag will not be set.But other times it works.

 


I want to know what's wrong with the code?Thanks.

0 Likes
2 Replies
MsMdt
Employee
Employee
10 replies posted 5 replies posted First reply posted

Hi, whenever you get a trap, it is good to collect additional information about it from the CPU registers. If there is more information you can check in the User Manual of the device and the respective TriCore Architecture Manual in the Trap chapter. This provides a good lead usually. With more information it is easier to identify your problem.

0 Likes
Chaabane
Level 3
Level 3
First solution authored First like received 10 replies posted

Hello,

 

Have you been able to figure out the issue ? I'm having the same !

0 Likes