Close

Free RTOS Success!

A project log for MyComm

A portable, solar powered, handheld device that provides truly global messaging when you have no alternative.

jack-wellsJack Wells 06/16/2016 at 09:570 Comments

I was able to add the Free RTOS to the GUI MyComm code. The main GUI runs in a dedicated task and a secondary task is running which prints out memory usage details. The standard Arduino "Loop" function also runs as an "idle" task. When nothing else is running then the Arduino Loop function is called. The Setup looks like this:

    xTaskCreate(vMainGUITask,
    "Task1",
    configMINIMAL_STACK_SIZE + 10500,
    NULL,
    tskIDLE_PRIORITY + 2,
    &gui);

    // create print task
    xTaskCreate(vPrintTask,
    "Task2",
    configMINIMAL_STACK_SIZE + 120,
    NULL,
    tskIDLE_PRIORITY + 3,
    NULL);

    // start FreeRTOS
    vTaskStartScheduler();

"Task 1" is the main GUI code. It has a larger configured stack size ("+10500") due to the size of the code and the fact it loads images. This may be reduced in the future depending on how testing goes.

"Task 2" is the debug printing task. It has a smaller stack due to the lack of functionality and low memory requirements. You'll notice it's priority is "+3". This means it is a higher priority than Task 1. The advantage of this is that the debug print task will always be run no matter what state the GUI task is.

Initially I had the GUI task as the highest priority; My thinking was I don't want anything to interrupt the users inputs. However, this meant that I had to "release" the task in order for the other tasks to get any run time. There are number of infinite while loops within the GUI code when it waits for user input. Placing a "taskdelay" within each section of the code would allow the other tasks to run but would be cumbersome and counter intuative to what I'm trying to achieve with FRTOS. For now I've lowered the priority in order that the debug tasks runs automatically without me having to decide when; This may change in the future depending on testing. For now the GUI is showing on the screen and I see no lag or degradation in user experience since changing over to FRTOS.

The beauty of Free RTOS is that I can make a dedicated task, test the code and then implement it by calling a new task. There's no need to work out when the new code must be called or any timings to adjust. Memory management is still a consideration that I'm keeping an eye. The flexibility of Free RTOS showed it's self when I started work on communicating with the iridium modem. There's a simple library (IridiumSBD) available that handles the communications protocols so within 5 minutes I had a task running that queried the Modem's signal strength. Made a global variable and now the top section of the display shows the current signal strength. Easy! It's going to take so more work to get messaging up and running but I'm not daunted by this.

*I'll add an image once my wifi is more stable

JW

Discussions