- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Labels:
-
AURIX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.