Effacer les filtres
Effacer les filtres

Concurrent task does not update absolute timer for sample time

3 vues (au cours des 30 derniers jours)
shi chen
shi chen le 4 Avr 2019
I use the concurrent task to generate the code. As shown in Figure 1, S1 and S2 are two model blocks.When generating code, S1 has two timers, but only one is updated in the ‘update function’. Only update task_M[0]->Timing.t[0].
This caused an error under concurrent tasks.
Figure1 concurrent
/* Update for Task: Periodic_Task1 */
void Periodic_Task1_update(void) /* Sample time: [0.1234s, 0.0s] */
{
/* Update for ModelReference: '<Root>/Sys1' */
S1_Update();
/* Update absolute time for base rate */
/* The "clockTick0" counts the number of times the code of this task has
* been executed. The absolute time is the multiplication of "clockTick0"
* and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
* overflow during the application lifespan selected.
* Timer of this task consists of two 32 bit unsigned integers.
* The two integers represent the low bits Timing.clockTick0 and the high bits
* Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
*/
if (!(++task_M[0]->Timing.clockTick0)) {
++task_M[0]->Timing.clockTickH0;
}
task_M[0]->Timing.t[0] = task_M[0]->Timing.clockTick0 * task_M[0]
->Timing.stepSize0 + task_M[0]->Timing.clockTickH0 * task_M[0]
->Timing.stepSize0 * 4294967296.0;
}
When I use single-task mode, both timers are updated.As shown in Figure 2 cs_SIL_M->Timing.t[0] and cs_SIL_M->Timing.t[1] are both updated.
Figure2 single task
/* Update absolute time for base rate */
/* The "clockTick0" counts the number of times the code of this task has
* been executed. The absolute time is the multiplication of "clockTick0"
* and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
* overflow during the application lifespan selected.
* Timer of this task consists of two 32 bit unsigned integers.
* The two integers represent the low bits Timing.clockTick0 and the high bits
* Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
*/
if (!(++cs_SIL_M->Timing.clockTick0)) {
++cs_SIL_M->Timing.clockTickH0;
}
cs_SIL_M->Timing.t[0] = cs_SIL_M->Timing.clockTick0 *
cs_SIL_M->Timing.stepSize0 + cs_SIL_M->Timing.clockTickH0 *
cs_SIL_M->Timing.stepSize0 * 4294967296.0;
{
/* Update absolute timer for sample time: [0.1234s, 0.0s] */
/* The "clockTick1" counts the number of times the code of this task has
* been executed. The absolute time is the multiplication of "clockTick1"
* and "Timing.stepSize1". Size of "clockTick1" ensures timer will not
* overflow during the application lifespan selected.
* Timer of this task consists of two 32 bit unsigned integers.
* The two integers represent the low bits Timing.clockTick1 and the high bits
* Timing.clockTickH1. When the low bit overflows to 0, the high bits increment.
*/
if (!(++cs_SIL_M->Timing.clockTick1)) {
++cs_SIL_M->Timing.clockTickH1;
}
cs_SIL_M->Timing.t[1] = cs_SIL_M->Timing.clockTick1 *
cs_SIL_M->Timing.stepSize1 + cs_SIL_M->Timing.clockTickH1 *
cs_SIL_M->Timing.stepSize1 * 4294967296.0;
}

Réponses (0)

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by