cancel
Showing results for 
Search instead for 
Did you mean: 

FREE_RTOS

Jean DEMBEGA
Associate II
Posted on May 24, 2018 at 12:53

Hey,

I am getting started with FreeRTOS on NUCLEO-FO72RB.

i set UART communication using DMA.

i would like to writre tu UART from muliple taske using queue with size of 16 items;

so i created 3 tasks.

- one task1 to receive to read Data from Queue and send it to UART DMA; this task run each 1000ms to take data from queue

- on task 'SW' that write to queue each 100ms the string 'Hey from SW Task; cnt2= %u';

- one task 'ADC' that write to queue each 200ms the string 'Hey from ADC Task; cnt1=%u' ;

the idea is that the 'SW' will load each time 2 data in queue and then 'ADC' load on Data.

but when i run the code, � got this in virtual terminal:

Hey from SW Task; cnt2= 1

Hey from ADC Task; cnt1= 6

Hey from SW Task; cnt2= 12

Hey from ADC Task; cnt1= 8

Hey from SW Task; cnt2= 12

Hey from SW Task; cnt2= 12

Hey from ADC Task; cnt1= 11

Hey from SW Task; cnt2= 12

Hey from SW Task; cnt2= 12

Hey from ADC Task; cnt1= 14

Hey from SW Task; cnt2= 12

Hey from SW Task; cnt2= 12

Hey from ADC Task; cnt1= 17

Hey from SW Task; cnt2= 12

Hey from SW Task; cnt2= 12

Hey from ADC Task; cnt1= 20

Hey from SW Task; cnt2= 12

Hey from SW Task; cnt2= 12

Hey from ADC Task; cnt1= 23

Hey from ADC Task; cnt1= 24

Hey from ADC Task; cnt1= 25

Hey from ADC Task; cnt1= 26

Hey from ADC Task; cnt1= 27

Hey from ADC Task; cnt1= 28

Hey from ADC Task; cnt1= 29

Hey from ADC Task; cnt1= 30

Hey from ADC Task; cnt1= 31

Hey from ADC Task; cnt1= 32

Hey from ADC Task; cnt1= 33

Hey from ADC Task; cnt1= 34

Hey from ADC Task; cnt1= 35

could someone tel me what is the mistake? in joined the code for kiel �Vision V5.

#stm32cubemx
3 REPLIES 3
Artur IWANICKI
ST Employee
Posted on May 24, 2018 at 13:16

Hello,

Your SW Task has lower priority than Main and ADC ones, thus it is quite difficult to get CPU time by this task. Have you checked how much time you need to one loop of each task function?

sprint and printf functions are quite heavy in terms of execution time.

Best Regards,

Artur

Jean DEMBEGA
Associate II
Posted on May 24, 2018 at 16:40

Hey Artur I,

i modifed the code by setting SW task priority as Main and ADC tasks,

i also use mutex when trying to access to the queue, and change Main Task periode to 100ms.

and now i get this result:

Hey from SW Task; cnt2= 1

Hey from ADC Task; cnt1= 1

Hey from SW Task; cnt2= 3

Hey from ADC Task; cnt1= 2

Hey from SW Task; cnt2= 5

Hey from SW Task; cnt2= 6

Hey from ADC Task; cnt1= 4

Hey from SW Task; cnt2= 8

Hey from SW Task; cnt2= 9

Hey from ADC Task; cnt1= 5

Hey from SW Task; cnt2= 11

Hey from SW Task; cnt2= 12

Hey from ADC Task; cnt1= 7

Hey from SW Task; cnt2= 14

Hey from SW Task; cnt2= 15

Hey from ADC Task; cnt1= 8

Hey from SW Task; cnt2= 17

as you can see their is data lost on SW Task.

also how can i checked how much time it need to one loop of each task function?

________________

Attachments :

main.c.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxYq&d=%2Fa%2F0X0000000azu%2FrqL1PZvZ7ThAfFfD3hEyAH2FMcBg3oQDg5b6m3NZytQ&asPdf=false
Artur IWANICKI
ST Employee
Posted on May 25, 2018 at 08:54

Hello,

Usually I am using a standard ping toggling (HAL_GPIO_TogglePin() of one of the remaining pins) or I am using EVENTOUT function of the pin (it is connecting the pin to the core, and once you execute 'sev' assembly instruction you will see a pulse on all of the pins configured to EVENTOUT configuration.

I am attaching you modified code (main.c file -> please have a look at StartSW_Task() function and

#stm32cubemx

project where you can find IO configuration).

Best Regards,

Artur

________________

Attachments :

My_OS.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxYl&d=%2Fa%2F0X0000000azr%2F_BRHXH2VyEx05yO7BVTqJNVeOdWOvE4O9pI0Iat_vB8&asPdf=false

main.c.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxYg&d=%2Fa%2F0X0000000azs%2FwOURe3ChCuY.qKNadqcRiqCJqzL_2pkTh1bybwcy9TE&asPdf=false