Hard Fault from FREERTOS example

Sysprogs forums Forums VisualGDB Hard Fault from FREERTOS example

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26999
    haasg
    Participant

    I’m currently trying to get FreeRTOS working on a STM32H743ZI. However enabling the system clock to run off the PPL and turning on the Hardware FPU is leading me to a hard fault. It should be relatively easy to recreate. I’m simply creating an embedded project for the STM32H743ZI with all the defaults and selecting the FreeRTOS example at the end of the setup wizard. The only thing I’m changing to the example is adding this code to initialize the system clock to 480MHz.

    RCC_OscInitTypeDef RCC_OscInitStruct = {0};
    RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

    /** Supply configuration update enable
    */
    HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
    /** Configure the main internal regulator output voltage
    */
    __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);

    while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
    /** Initializes the CPU, AHB and APB busses clocks
    */
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
    RCC_OscInitStruct.HSEState = RCC_HSE_ON;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
    RCC_OscInitStruct.PLL.PLLM = 5;
    RCC_OscInitStruct.PLL.PLLN = 192;
    RCC_OscInitStruct.PLL.PLLP = 2;
    RCC_OscInitStruct.PLL.PLLQ = 2;
    RCC_OscInitStruct.PLL.PLLR = 2;
    RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
    RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
    RCC_OscInitStruct.PLL.PLLFRACN = 0;
    HAL_StatusTypeDef status1 = HAL_RCC_OscConfig(&RCC_OscInitStruct);
    if(status1 != HAL_OK)
    {
    //Error_Handler();
    }
    /** Initializes the CPU, AHB and APB busses clocks
    */

    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
    | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2
    | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1;
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
    RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
    RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
    RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;

    HAL_StatusTypeDef status2 = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
    if(status2 != HAL_OK)
    {
    //Error_Handler();
    }

    It returns HAL_OK and sets the clocks correctly, threads run fine, led blinks, (with hardware FPU off). However, once the FPU is turned on, as soon as the thread runs through once and goes to yield with “portYIELD_WITHIN_API();” the program jumps to a hard fault. Turning the hardware FPU off or running off the internal clock seem to fix the issue however doing so isn’t really a viable work around. I’m not really sure how the clock, FPU, and FreeRTOS would interact to create such a hard fault but it does seem odd they would do so with so little changed to the example code starting point.

    Perhaps I’m missing something obvious but I’ve scoured the internet and haven’t been able to figure out what’s going on, any help would be much appreciated. I’ll attach the entire main file also.

     

    Right before fault

    https://gyazo.com/a7ec1c0af05835a878c6726e0492d0ca

    Attachments:
    You must be logged in to view attached files.
    #27001
    support
    Keymaster

    Hi,

    Sorry, it looks like the issue it not caused by VisualGDB, but instead some STM32-specific clock settings might be incorrect. Please consider posting on the STM32 forums to get help specific to STM32 devices.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.