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

    :(

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

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

    :(

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

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