Please enable JavaScript to view this site.

Waijung 2 User Guide

How this block appears in a Simulink model?

FreeRTOS_task_block_1

What can be configured?

freertos-task

Configuration Parameter

Selectable Option/Value

Description

Specify ESP32 core to use

Check--Uncheck

If the user uncheck this, the task will be automatically allocated to a core by FreeRTOS

Run on core

Protocol CPU (CPU 0)--Application CPU (CPU 1)

This option will only be visible when Specify ESP32 core to use is Checked. Select the ESP32 core to which the task should be assigned.

Invoke from

Interrupt Service Routine--Function-call Generator

This block can be invoked from two methods:

1. Invoke from an Interrupt Service Routine (ISR): This block can be invoked from an ISR such as the Timer interrupt block. The output of the Timer Interrupt block should be connected to the input of this block. This method is recommended for time-critical operations.

2. Invoke from Function-call Generator: When this method is selected, the output of the Function-call Generator should be connected to the input of this block

Task name [pcName] (10 characters or less):

 

Enter the name of the task (10 characters or less). This field should not be left empty. Task name of two FreeRTOS Task blocks cannot be the same.

Task priority [uxPriority]:

0 to configMAX_PRIORITIES

Enter the task priority. configMAX_PRIORITIES should be specified in the Waijung 2 Target Setup block Highest (maximum) priority mask parameter. A higher number gives higher priority to the task. same priority will share the available processing time using a time-sliced round-robin scheduling scheme. More information on FreeRTOS task priority can be found here.

Stack depth [usStackDepth] (words):

 

The number of words (not bytes!) to allocate for use as the task's stack. For example, if the stack is 16-bits wide and usStackDepth is 100, then 200 bytes will be allocated for use as the task's stack. As another example, if the stack is 32-bits wide and usStackDepth is 400 then 1600 bytes will be allocated for use as the task's stack. The stack depth multiplied by the stack width must not exceed the maximum value that can be contained in a variable of type size_t. See the FAQ How big should the stack be? for more information.

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

Input

 

function-call events


Output

 

function-call events


When to use this block?

This block can be used to create FreeRTOS tasks with a chosen priority using the xTaskCreate function

How does this block work?

To use this block, all the functions that should be executed within a FreeRTOS task should be put in one Function-call Subsystem and connected to the output port of this block.

Demo

Demo file : esp32_freertostask_demo.slx

FreeRTOS_task_block_3

Description

This demo shows how to use the FreeRTOS task block. In the model, the task is invoked using a Function-call Generator block in Simulink that is set to a sample time of 1 second. Inside the Function-call Subsystem a simple print command is used to monitor the task execution.

Setup

A serial monitor software application is required to get the expected results. For this example, PuTTY open-source SSH and telnet client is used to monitor the serial output.

What should be happening?

After the model file is compiled and uploaded to the ESP32 board, open the PuTTY software and connect to the relevant serial port with a baud rate of 115200. The following output should be visible on the serial monitor software. The print statement shown below is printed every 1 second.

FreeRTOS_task_block_4

Copyright 2024 Aimagin Co.,Ltd. Rev.1659