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 12:10

Most of the job in my project is done by STM32CubeMX (FreeRTOS configuration, task, queues, semaphores definitions). Then in the code I am doing only some interrupt callbacks and task functions. What I would do is to compare first settings of FreeRTOS in yours and mine project and then after your code regeneration check your code with my proposal. All of mine code is placed within /*USER CODE BEGIN */ and /*USER CODE END */ lines, so it is quite easy to identify what has been generated by STM32CubeMx and what by me.

Jessy J
Associate II
Posted on May 16, 2018 at 12:15

your code and mine are not same because it depends on the KIT STM32 . I am using STM32F4 ..

for example in my main.c

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_ADC1_Init(void);

static void MX_DSIHOST_DSI_Init(void);

static void MX_FMC_Init(void);

static void MX_QUADSPI_Init(void);

//static void MX_SDIO_MMC_Init(void);

static void MX_USART1_UART_Init(void);

static void MX_USB_OTG_FS_PCD_Init(void);

static void MX_USB_OTG_HS_PCD_Init(void);

void StartDefaultTask(void const * argument);

static void MX_NVIC_Init(void);

static void Netif_Config(void);

static void ToggleLED4(void const * argument);

It is not same as yours so I think I wil not be able to use yours right ? 

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

your code and mine are not same because it depends on the KIT STM32 . I am using STM32F4 ..

for example in my main.c

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_ADC1_Init(void);

static void MX_DSIHOST_DSI_Init(void);

static void MX_FMC_Init(void);

static void MX_QUADSPI_Init(void);

//static void MX_SDIO_MMC_Init(void);

static void MX_USART1_UART_Init(void);

static void MX_USB_OTG_FS_PCD_Init(void);

static void MX_USB_OTG_HS_PCD_Init(void);

void StartDefaultTask(void const * argument);

static void MX_NVIC_Init(void);

static void Netif_Config(void);

static void ToggleLED4(void const * argument);

It is not same as yours so I think I wil not be able to use yours right ? 

Artur IWANICKI
ST Employee
Posted on May 16, 2018 at 12:35

Yours is much more advanced, but as I see you have 2 task functions:

void StartDefaultTask(void const * argument);

static void ToggleLED4(void const * argument);

All of the functions with MX prefix are automatically generated by STM32CubeMX and its role is to perform configuration of given peripheral based on configuration done in Configuration tab within STM32CubeMX.

I would start with simplest possible configuration and add peripheral by peripheral.

In your application I would check the priority levels of all peripherals whether those are on higher level (lower number) than specified in FreeRTOS configMAX_SYSCALL_INTERRUPT_PRIORITY (5 in your case).

More complex example for the board you are using can be found within STM32F4 Cube pack in the path:

.\STM32Cube_FW_F4_V1.21.0\Projects\STM32469I_EVAL\Demonstrations\STemWin\

Best Regards,

Artur

Jessy J
Associate II
Posted on May 16, 2018 at 12:58

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

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

<

https://community.st.com/www.freertos.org/FAQHelp.html

>

for

more tips, and ensure configASSERT() is defined!

/external-link.jspa?url=http%3A%2F%2Fwww.freertos.org%2Fa00html%23configASSERT

<

https://community.st.com/www.freertos.org/a00html#configASSERT

>

1) Stack overflow -

see

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

<

https://community.st.com/www.freertos.org/Stacks-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

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

<

https://community.st.com/www.freertos.org/RTOS-Cortex-M3-M4.html

>

and the definition

of configMAX_SYSCALL_INTERRUPT_PRIORITY on

/external-link.jspa?url=http%3A%2F%2Fwww.freertos.org%2Fa00html

<

https://community.st.com/www.freertos.org/a00html

>

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. */

}

}

What shall I correct when it comes to this function . What is the error

Artur IWANICKI
ST Employee
Posted on May 16, 2018 at 13:46

Could you please pass me part of your code where you put HAL_Delay() and you stuck + body of used HAL_Delay() function?

Jessy J
Associate II
Posted on May 16, 2018 at 13:59

Here is the file that ocntans the HAL_delay 

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

/* Cortex-M4 Processor Interruption and Exception Handlers */

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

/**

* @brief This function handles NMI exception.

* @param None

* @retval None

*/

void NMI_Handler(void)

{

}

/**

* @brief This function handles Hard Fault exception.

* @param None

* @retval None

*/

void HardFault_Handler(void)

{

/* Go to infinite loop when Hard Fault exception occurs */

while (1)

{

}

}

/**

* @brief This function handles Memory Manage exception.

* @param None

* @retval None

*/

void MemManage_Handler(void)

{

/* Go to infinite loop when Memory Manage exception occurs */

while (1)

{

}

}

/**

* @brief This function handles Bus Fault exception.

* @param None

* @retval None

*/

void BusFault_Handler(void)

{

/* Go to infinite loop when Bus Fault exception occurs */

while (1)

{

}

}

/**

* @brief This function handles Usage Fault exception.

* @param None

* @retval None

*/

void UsageFault_Handler(void)

{

/* Go to infinite loop when Usage Fault exception occurs */

while (1)

{

}

}

/**

* @brief This function handles SVCall exception.

* @param None

* @retval None

*/

/*void SVC_Handler(void)

{

}*/

/**

* @brief This function handles Debug Monitor exception.

* @param None

* @retval None

*/

void DebugMon_Handler(void)

{

}

/**

* dummy function to avoid the standard initialization code

*/

HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)

{

return HAL_OK;

}

/**

* @brief Get the value of the Kernel SysTick timer

* @param None

* @retval None

* @note MUST REMAIN UNCHANGED: \b osKernelSysTick shall be consistent in every CMSIS-RTOS.

*/

uint32_t HAL_GetTick(void)

{

return xTaskGetTickCount();

}

/**

* @brief This function handles System tick timer.

*/

void SysTick_Handler(void)

{

/* USER CODE BEGIN SysTick_IRQn 0 */

if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)

{

xPortSysTickHandler();

}

/* USER CODE END SysTick_IRQn 0 */

/* USER CODE BEGIN SysTick_IRQn 1 */

/* USER CODE END SysTick_IRQn 1 */

}

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);

}

//void vApplicationTickHook ( void )

//

//{

// HAL_IncTick ();

//}

while debugging : in the tasks.c file in the this fuction 

TickType_t xTaskGetTickCount( void )

{

TickType_t xTicks;

/* Critical section required if running on a 16 bit processor. */

portTICK_TYPE_ENTER_CRITICAL();

{

xTicks = xTickCount;

}

portTICK_TYPE_EXIT_CRITICAL();

return xTicks;

}

in debug xTicks remains always 0 and do not increment I do not know why

Artur IWANICKI
ST Employee
Posted on May 16, 2018 at 14:20

I see in your code that you have changed HAL_Delay() and you are calling there vTaskDelay().

If you do like this and you will use HAL_Delay() within any HAL function you will be dependent on FreeRTOS and SysTick which has lowest possible interrupt priority and can block your interrupts.

Could you please leave HAL_Delay() function not changed after generation by STM32CubeMX and check your project once again whether you will be blocked?

Posted on May 16, 2018 at 12:21

 ,

 ,

Your code and mine are not same because it depends on the KIT STM32 . I am

using STM32F4 ..

for example in my main.c

void SystemClock_Config(void),

static void MX_GPIO_Init(void),

static void MX_ADC1_Init(void),

static void MX_DSIHOST_DSI_Init(void),

static void MX_FMC_Init(void),

static void MX_QUADSPI_Init(void),

//static void MX_SDIO_MMC_Init(void),

static void MX_USART1_UART_Init(void),

static void MX_USB_OTG_FS_PCD_Init(void),

static void MX_USB_OTG_HS_PCD_Init(void),

void StartDefaultTask(void const * argument),

static void MX_NVIC_Init(void),

static void Netif_Config(void),

static void ToggleLED4(void const * argument),

It is not same as yours so I think I wil not be able to use yours right ?

2018-05-16 12:11 GMT+02:00 Artur I <,st-microelectronics@jiveon.com>,:

STMicroelectronics Community

<,https://community.st.com/?et=watches.email.thread>,

Re: How to configure the freertos interruption ?

reply from Artur I

<,https://community.st.com/people/iwanicki.artur?et=watches.email.thread>,

in STM32 MCUs Forum - View the full discussion

<,https://community.st.com/message/197633-re-how-to-configure-the-freertos-interruption?commentID=197633&,et=watches.email.thread ♯ comment-197633>,

Jessy J
Associate II
Posted on May 16, 2018 at 14:23

Here is the original delay in stm32f4xx_hal.c

@verbatim

===============================================================================

##### HAL Control functions #####

===============================================================================

[..] This section provides functions allowing to:

(+) Provide a tick value in millisecond

(+) Provide a blocking delay in millisecond

(+) Suspend the time base source interrupt

(+) Resume the time base source interrupt

(+) Get the HAL API driver version

(+) Get the device identifier

(+) Get the device revision identifier

(+) Enable/Disable Debug module during SLEEP mode

(+) Enable/Disable Debug module during STOP mode

(+) Enable/Disable Debug module during STANDBY mode

@endverbatim

* @{

*/

/**

* @brief This function is called to increment a global variable 'uwTick'

* used as application time base.

* @note In the default implementation, this variable is incremented each 1ms

* in SysTick ISR.

* @note This function is declared as __weak to be overwritten in case of other

* implementations in user file.

* @retval None

*/

__weak void HAL_IncTick(void)

{

uwTick += uwTickFreq;

}

/**

* @brief Provides a tick value in millisecond.

* @note This function is declared as __weak to be overwritten in case of other

* implementations in user file.

* @retval tick value

*/

__weak uint32_t HAL_GetTick(void)

{

return uwTick;

}

/**

* @brief This function returns a tick priority.

* @retval tick priority

*/

uint32_t HAL_GetTickPrio(void)

{

return uwTickPrio;

}

/**

* @brief Set new tick Freq.

* @retval Status

*/

But I should re write it since it is weak function right ? I have to adapt it freeRRTOS functinos right ?