Go Down

Topic: [Solved] RTOS for DUE. uMT or other? Problems with uMT (Read 291 times) previous topic - next topic

DrAngelOK

Good day.
I need to run tasks after a certain time.
1. First, I used the following code to run:

Code: [Select]


void loop()
{
//if (tc % 10 == 0) my_loop_10ms();
//if (tc % 100 == 0) my_loop_100ms();
//if (tc % 1000 == 0) my_loop_1s();
//if (tc % 2000 == 0) my_loop_2s();
//if (tc % 60000 == 0) my_loop_1m();
//if (tc == 60000) my_loop_1m();
//if (tc % 300000 == 0) {
// my_loop_5m();
// tc = 0;
}


2. Then I switched to using DueTimer:

Code: [Select]


void setup()
{
Timer0.attachInterrupt(my_loop_rt).start(1000);
Timer1.attachInterrupt(my_loop_10ms).start(10000);
Timer2.attachInterrupt(my_loop_100ms).start(100000);
Timer3.attachInterrupt(my_loop_1s).start(1000000);
Timer4.attachInterrupt(my_loop_2s).start(2000000);
Timer5.attachInterrupt(my_loop_1m).start(60000000);
Timer6.attachInterrupt(my_loop_5m).start(300000000);

void loop() {}


For some reason, I thought that DueTimer would provide parallel execution of tasks.
But with the addition of the AT 2320 sensor, the system began to freeze. The same code at system startup when everything is executed sequentially - works correctly.

Found several libraries - I don't know which one to choose.
In addition, I had problems understanding the logic of uMT.

DrAngelOK

My code for uMT:

Code: [Select]

void setup()
{
   my_umt_init();
   my_umt_tasks();
}

void loop()
{
my_loop_1s();
my_loop_2s();
}

void my_umt_init(void)
{
uMTcfg umtCfg;
Kernel.Kn_GetConfiguration(umtCfg);
umtCfg.rw.Tasks_Num = 20;
umtCfg.rw.Semaphores_Num = 32;
umtCfg.rw.AgentTimers_Num = 20;
umtCfg.rw.AppTasks_Stack_Size = 512;
umtCfg.rw.Task1_Stack_Size = 512;
umtCfg.rw.Idle_Stack_Size = 512;
umtCfg.rw.BlinkingLED = true;
umtCfg.rw.IdleLED = true;
umtCfg.rw.TimeSharingEnabled = true;
error = Kernel.Kn_Start(umtCfg);

if (error == 0)
{
my_print("uMT Start OK");
};
}

void my_umt_tasks(void) {
TaskId_t TEvev_1s;
TaskId_t TEvev_2s;
Kernel.Tk_CreateTask(my_loop_1s, TEvev_1s);
Kernel.Tk_CreateTask(my_loop_2s, TEvev_2s);

Kernel.Tk_StartTask(TEvev_1s);
Kernel.Tk_StartTask(TEvev_2s);

}

void my_loop_1s(void)
{
TimerId_t Tm_1s;
//Kernel.Tm_EvEvery(TEST_TIMEOUT1, EVENT_A, Tm_1s);
Kernel.Tm_EvEvery(1000, 1, Tm_1s); // Wake up after ... seconds
<...my functions...>
}

void my_loop_2s(void)
{
Errno_t error;
TimerId_t Tm_2s;
//Kernel.Tm_EvEvery(TEST_TIMEOUT1, EVENT_A, Tm_1s);
Kernel.Tm_EvEvery(2000, 1, Tm_2s); // Wake up after ... seconds

Event_t eventout;
error = Kernel.Ev_Receive(1, uMT_ANY, &eventout);

if (error != E_SUCCESS)
{

}
else
{
if (eventout != 1)
{

}
else
{
Serial.print(F(" EvEvery(): INVALID EVENT received = 333 "));
Serial.println((unsigned)eventout);
Serial.flush();

<...my functions...>
}
}
}



I can not understand the logic of construction.

ard_newbie


Did you read the Getting Started uMT tutorial that you can find with the uMT library ?

Is it a Uni assignment ?

Did you try using tc_lib from antodom to start execution of tasks without any RTOS ?

DrAngelOK

Did you read the Getting Started uMT tutorial that you can find with the uMT library ?

Is it a Uni assignment ?

Did you try using tc_lib from antodom to start execution of tasks without any RTOS ?
1. Yes. Sure. And now I'm re-reading.
2. I did not understand the question.
3. No. Now I am trying an example from uMT.

I can not understand how to do without loop ().

DrAngelOK

The problem is resolved. There is an error in the library example.

Go Up