AZURE-RTOS ThreadX in the STM32Cube ecosystem
ThreadX
1.Blink Led :
step 0 : Prepare project for CubeMX and CubeIDE
step1 :blink led
1.Create first thread :
step2 : Add ThreadX in CubeMX
In CubeMX Tab:
- Software packs
- Select components
Step3 : Add ThreadX into CubeIDE project
- RTOS ThreadX
- Save project CTRL+S(this will generate ThreadX files to our project)
- Selection of TimeBase : TIM6
If HAL library don’t have separated time source the compilation will fail because both libraries want to use SysTick_Handler interrupt .
ThreadX basic :
ThreadX is called from main.c over
MX_AZURE_RTOS_Init
function. Inside is a call to tx_kernel_enter
which will initialize ThreadX and start it. Before ThreadX is started. The tx_application_define
is called where used can allocate his memory, create tasks and other items from ThreadX. After this function ends ThreadX is started.Basic thread states
ThreadX memory pools
For memory allocation in ThreadX is possible to use two aproaches.
- Byte pool allocation
- Block pool allocation
Byte pool
For byte pool creation is used function tx_byte_pool_create
for this we need to create an array from which memory will be distributed and structure TX_BYTE_POOL
to handle our byte pool informations.
Block pool
The block pool is very similar to byte bool. Main difference is in allocation. When block size is fixed and used as parrameter for tx_block_pool_create
. ThreadX will calculate how namy blocks as possible to create and each tx_block_allocate
will take one block.
Commentaires
Enregistrer un commentaire