Hi,
Using schedule table of NXP RTOS, privided in SAF, an edge case has been founded during test. It seems that RTOS dosen't take it into consideration. Let me explain this.
Above two examples explain the logic of OSSyncScheduleTable. One is a well-operating case, the other is an edge case that is not treated properly.
For deltaTime to be calculated correctly in the above logic in the edge case, the Next EP value corresponding to sctCB->almId->value should have been updated to the 2nd Next EP. The reason why it wasn't updated hasn't been analyzed. An ISR should have operated at Next EP, and within that, the schedule table's almId->value should have been updated... But it wasn't. Anyway, since it wasn't updated, the following inversion phenomenon occurs.
With sctCB->almId->value = 0x355C18A8, CTR(STM2 TimeBase) = 0x355C18A9, Although the code handles inversions caused by TimeBase overflow, but it doesn't prepare for inversions like this edge case. If we trace the deltaTime value:
deltaTime = sctCB->almId->value - ctrValue
/* deltaTime = 0xFFFFFFFF */
deltaTime += OsCountersCfg[ctrInd].maxallowedvalue + 1U
/* deltaTime = 0xFFFFFFFF + 0xFFFFFFFF + 1 = 0xFFFFFFFF */
deltaTime = ((OSSCTEPEXPL ) sctCB->currentEP)->offset - deltaTime
/* deltaTime = 50000 - 0xFFFFFFFF = 50000 + 1 = 50001 */
deltaTime += sctCB->length
/*deltaTime = 50001 + 50000 = 100001 */
Finally, the deviation value becomes sctDB->deviation = 150001
Here's an T32 screenshot for the edge case.
Temporary workaround from us is like below. Please consider that this is reasonable for NXP RTOS experts.
In the edge case, since ctrValue > sctCB->almId->value and deltaTime would be recognized as a negative number when treated as a signed integer, we will calculate the new DeltaTime by simply adding a condition to convert deltaTime to a positive number by taking its two's complement.
deltaTime = sctCB->almId->value - ctrValue; if ((ctrValue > sctCB->almId->value) && ((deltaTime >= 0x80000000) && (deltaTime <= 0xFFFFFFFF))) { deltaTime = OsCountersCfg[ctrInd].maxallowedvalue - deltaTime + 1U; } else { ..Legacy logic.. }
Anyone who can answer?