Skip to main content
Jessy J
Associate III
May 14, 2018
Question

F

  • May 14, 2018
  • 41 replies
  • 4415 views

.

    This topic has been closed for replies.

    41 replies

    ST Employee
    May 16, 2018
    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
    Jessy JAuthor
    Associate III
    May 16, 2018
    Posted on May 16, 2018 at 12:48

     ,

     ,

    I was referred to the project of F4 you told me.. but it is always the same

    problem blocked in the list.c file in the for loop I sent you.

    Can you help me to know what is missed or incorrect ????

    Thank you

    Le mer. 16 mai 2018 à 12:36, Artur I <,st-microelectronics@jiveon.com>, a

    écrit :

    STMicroelectronics Community

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

    Re: How to configure the freertos interruption ?

    reply from Artur I

    <,

    in STM32 MCUs Forum - View the full discussion

    <,https://community.st.com/0D70X000006SqvoSAC

    Jessy J
    Jessy JAuthor
    Associate III
    May 16, 2018
    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

    ST Employee
    May 16, 2018
    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
    Jessy JAuthor
    Associate III
    May 16, 2018
    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

    ST Employee
    May 16, 2018
    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?

    Jessy J
    Jessy JAuthor
    Associate III
    May 16, 2018
    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 ? 

    ST Employee
    May 16, 2018
    Posted on May 16, 2018 at 14:30

    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().

    Jessy J
    Jessy JAuthor
    Associate III
    May 16, 2018
    Posted on May 16, 2018 at 14:30

    when I leave it not changed it is blocked here 

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

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

    {

    }

    }
    ST Employee
    May 17, 2018
    Posted on May 17, 2018 at 07:20

    Hello,

    Are you able to identify in which part of the code you are calling HAL_Delay() which is creating an issue, please?

    Are you using this functions in task functions:

    void StartDefaultTask(void const * argument);

    static void ToggleLED4(void const * argument); ?

    Would it be possible for you to pass me a table (screenshoot from NVIC view from STM32CubeMX) with NVIC interrupts and its priorities, please?

    Thank you in advance,

    Best Regards,

    Artur

    Jessy J
    Jessy JAuthor
    Associate III
    May 17, 2018
    Posted on May 17, 2018 at 09:58

    I am using these functions as follow 

    void StartDefaultTask(void const * argument)

    {

    /* init code for FATFS */

    MX_FATFS_Init();

    /* init code for LWIP */

    MX_LWIP_Init();

    /* USER CODE BEGIN 5 */

    /* Initialize tcp echo server */

    tcp_echoserver_init();

    /* Notify user about the netwoek interface config */

    User_notification(&gnetif);

    /* Start toogleLed4 task : Toggle LED4 every 250ms */

    osThreadDef(LED4, ToggleLed4, osPriorityLow, 0, configMINIMAL_STACK_SIZE);

    osThreadCreate (osThread(LED4), NULL);

    /* Infinite loop */

    for(;;)

    {

    osDelay(1);

    }

    static void ToggleLed4(void const * argument)

    {

    /* toggle LED4 each 250ms */

    HAL_GPIO_TogglePin(LED4_GPIO_Port, LED4_Pin);

    osDelay(250);

    }

    I have a question . about TIM6 I should re write the void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) . but I did not know how 

    Y ou will find attached the NVIC ocnfiguration from STM32cubMX

    Thank you in advance0690X0000060KoYQAU.png0690X0000060Kp1QAE.png0690X0000060Kp6QAE.png