cancel
Showing results for 
Search instead for 
Did you mean: 

F

Jessy J
Associate II

.

41 REPLIES 41
Artur IWANICKI
ST Employee
Posted on May 16, 2018 at 10:04

Hello,

Your NVIC configuration looks correct. 

BASEPRI is the name of the core registers which is used to block interrupt on the desired level (always vs preemption priorities). As you see in above code you are configuring BASEPRI with configMAX_SYSCALL_INTERRUPT_PRIORITY (5 in your case). 

I see you are using os functions within HAL functions . 

I would separate those two worlds. Please select different timer (SYS->Timebase) for HAL libraries and leave SysTick for OS. It will help you with proper interrupt management.

If you will use Systick for HAL and OS you will face the situation that your SysTick interrupt (having lowest possible priority) will be stucked as it will be blocked by most of the OS functions at entrance to critical section (operations on BASEPRI).

Best Regards,

Artur

Jessy J
Associate II
Posted on May 16, 2018 at 10:11

Hello, 

I wanted to configure the interruptino using Systick and then change it to timer but it is not correct right ?? 

If no , which Timer shall I use in SYS PLEASE ?? 

Can You tell me more about timers and how to use it ? I am a debutant about timers 

Jessy J
Associate II
Posted on May 16, 2018 at 10:24

I changed it to tTIM6 .when I debug it blocks in the BASEPRI function I do not know why yet 

Artur IWANICKI
ST Employee
Posted on May 16, 2018 at 10:34

TIM6 is a good choice. 

Concerning timers introduction, I would recommend to you one of our dedicated application notes,

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/91/01/84/3f/7c/67/41/3f/DM00236305/files/DM00236305.pdf/jcr:content/translations/en.DM00236305.pdf

 where you will find more information. To track where you are blocked please check whether you are not using HAL_Delay function from interrupts or from tasks. From task it is better to use osDelay which is not blocking CPU.

Best Regards,

Artur

Jessy J
Associate II
Posted on May 16, 2018 at 10:38

HAL_delay function is weak function so I re wwrited it liks this

void HAL_Delay ( volatile uint32_t millis)

{

/* remplace la fonction de délai de blocage de la bibliothèque HAL avec l'équivalent de la reconnaissance de threads FreeRTOS */

osDelay (millis);

}

Still did not know how to resolve it

:(

 
Artur IWANICKI
ST Employee
Posted on May 16, 2018 at 10:48

Please, keep an original form of HAL_Delay() and please do not call from it any OS functions. HAL_Delay should have nothing in common with OS to have an option to work with the hardware.

HAL_Delay() in your case should generate delays, timeouts based on Timer6 events. Timer6 interrupt has higher priority (much above OS) to allow hardware, its interrupts to work and not be blocked by OS (within critical sections using BASEPRI).

Jessy J
Associate II
Posted on May 16, 2018 at 11:07

in stm32f4xx_it.c the HAL DELAY is like this 

__weak void HAL_Delay(uint32_t Delay)

{

uint32_t tickstart = HAL_GetTick();

uint32_t wait = Delay;

/* Add a freq to guarantee minimum wait */

if (wait < HAL_MAX_DELAY)

{

wait += (uint32_t)(uwTickFreq);

}

while((HAL_GetTick() - tickstart) < wait)

{

}

}

I do know why but I read somewhere that I hzve to re write it 

void HAL_Delay ( volatile uint32_t millis)

{

/* remplace la fonction de délai de blocage de la bibliothèque HAL avec l'équivalent de la reconnaissance de threads FreeRTOS */

/*(mappage HAL_Delay () à vTaskDelay () résout le problème du blocage d'une fonction dans un timeout)*/

vTaskDelay (millis);

}

I removed the osDelay . Is it fine noww ??? 

When I debug I put breakpoint on Hal_Delay . It blocks . when I put pause to see where it is blocked 

it is blocked in list.c file in for loop 

/* *** NOTE ***********************************************************

If you find your application is crashing here then likely causes are

listed below. In addition see

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fwww.freertos.org%2FFAQHelp.html

for

more tips, and ensure configASSERT() is defined!

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fwww.freertos.org%2Fa00110.html%23configASSERT

1) Stack overflow -

see

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fwww.freertos.org%2FStacks-and-stack-overflow-checking.html

2) Incorrect interrupt priority assignment, especially on Cortex-M

parts where numerically high priority values denote low actual

interrupt priorities, which can seem counter intuitive. See

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fwww.freertos.org%2FRTOS-Cortex-M3-M4.html

and the definition

of configMAX_SYSCALL_INTERRUPT_PRIORITY on

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fwww.freertos.org%2Fa00110.html

3) Calling an API function from within a critical section or when

the scheduler is suspended, or calling an API function that does

not end in 'FromISR' from an interrupt.

4) Using a queue or semaphore before it has been initialised or

before the scheduler has been started (are interrupts firing

before vTaskStartScheduler() has been called?).

**********************************************************************/

for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */

{

/* There is nothing to do here, just iterating to the wanted

insertion position. */

}

}
Jessy J
Associate II
Posted on May 16, 2018 at 11:07

Thank you for your help . I need help and i am debutant

:(

Artur IWANICKI
ST Employee
Posted on May 16, 2018 at 11:45

No problem, I am here to help you.

I am attaching a simple ready project on FreeRTOS and manual from one of our workshops. It is done on STM32F072 Nucleo board, but can be adapted to any STM Inside you will find a STM32CubeMX project (.ioc file), complete project for Keil uVision, but you can regenerate the code to any other IDE.

I hope it helps.

________________

Attachments :

Developing of typical 8-bit application with CubeMX and FreeRTOS.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hxcn&d=%2Fa%2F0X0000000b0G%2FpjYm.WhbfFlQsDQ_M1S_1L9IFmZWhYGQTmcjkWMm9eo&asPdf=false

Developing of typical 8-bit application with CubeMX and FreeRTOS.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hxcx&d=%2Fa%2F0X0000000b0H%2F3NUwOdhBgOG6MIoG3E9zOuO4kS_cz5LPHXyuK8xcHVI&asPdf=false
Jessy J
Associate II
Posted on May 16, 2018 at 11:53

I am using STM32479I EVAL BOARD. 

Shall I use the project you send me and make the modification in it ? 

Thank ou so much