Lab Assignment: FreeRTOS Tasks


To give you some experience in:

  1. Loading firmware onto the SJOne board
  2. Using FreeRTOS tasks and seeing how they behave


Part 1. Fill Out the Code

Use the following code template:

  1. Reference the code comments for what you need to do. 
  2. Fill out the xTaskCreate method parameters.
  3. Do not use printf, instead use uart0_puts() function from #include "uart0_min.h"

Set the priority of the two tasks to 1 (lower number = low priority)

FreeRTOSConfig.h defines the total priority levels, but for the template project it is likely to be 4

#include "FreeRTOS.h"
#include "task.h"
#include "uart0_min.h"

void vTaskOneCode(void)
    	vTaskDelay(100); // This sleeps the task for 100ms (because 1 RTOS tick = 1 millisecond)

// Create another task and run this code in a while(1) loop
void vTaskTwoCode(void)

// You can comment out the sample code of lpc1758_freertos project and run this code instead
int main(int argc, char const *argv[])
    /// This "stack" memory is enough for each task to run properly
    const uint32_t STACK_SIZE = 1024;
     * Observe and explain the following scenarios:
     * 1) Same Priority: A = 1, B = 1
     * 2) Different Priority: A = 2, B = 1
     * 3) Different Priority: A = 1, B = 2
     * Turn in screen shots of what you observed
     * as well as an explanation of what you observed
    xTaskCreate(vTaskOneCode, /* Fill in the rest parameters for this task */ );
    xTaskCreate(vTaskTwoCode, /* Fill in the rest parameters for this task */ );

    /* Start Scheduler - This will not return, and your tasks will start to run their while(1) loop */

    return 0;

Code Block 1: Main.cpp

Part 2: Make observations of the output

  • How come 4(or 3 sometimes) characters are printed from each task? Why not 2 or 5, or 6?
  • Alter the priority of one of the tasks, and note down the observations. Note down WHAT you see and WHY.
  • The printf data appears over 38400bps UART, which can roughly send 4 characters per millisecond
    When you send 20 chars (aaaaaaaaaaaaaaaaaaaa), it would take roughly 5ms to send the data
  • The SJ-One board RTOS runs at 1Khz meaning that 1 RTOS tick is 1 millisecond

Part 3. Change the priority levels

Now that you have the code running with identical priority levels do the following:

  1. Change the priority of the two tasks.
    • A=1, B=1
    • A=2, B=1
    • A=1, B=2
  2. Take a screenshot of what you see from the console.
  3. Write an explanation of why you think the output came out the way it did using your knowledge about RTOS.

What to turn in (to Canvas as PDF):

  1. Relevant code
  2. Your observation and explanation
  3. Snapshot of the output for all scenarios.


Back to top