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:

  1. Software packs
  2. Select components


  1. Open X-Cube-Azure-H7
  2. Opne RTOS : Select ThreadX / Core
  3. Click OK



Step3 : Add ThreadX into CubeIDE project 
Configure ThreadX mode
  1. Select software packs
  2. Select X-Cube-Azure-H7

  1. RTOS ThreadX
  2. Save project CTRL+S(this will generate ThreadX files to our project)
  3. 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.

  1. Byte pool allocation
  2. 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

Posts les plus consultés de ce blog

Azure RTOS with Stm32

STM32F7_HAL_ETH_MQTT_CLIENT