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:
/******************************************************************************//* 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)
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?
=============================================================================== ##### 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 ?
You could, but I see no reason why. FreeRTOS has its own delay functions which have completely different role than here. osDelay (vTaskDelay in FreeRTOS API) is used to move the active task to Blocked mode for a certain time giving CPU time to another task from ready group. HAL_Delay function is used to realize delays and timeouts within HAL functions and it should not call osDelay().