1.3k views
in System Integration by

Hi 

Board STM32F469 Discovery, IDE Keil, I am getting Random Hard Faults and the code is getting stuck at while( TransferInProgress ) in the follow code block

void EwBspGraphicsWaitForCompletion()
{
  /* return immediately if no DMA2D transfer is ongoing */
  if ( TransferInProgress == 0 )
    return;

  CPU_LOAD_SET_IDLE();

#ifdef EW_USE_DMA2D_INTERRUPT_MODE

  #if EW_USE_FREE_RTOS == 1

    osSemaphoreWait( AcceleratorSemaphoreId, 1000 );
    TransferInProgress = 0;

  #else

    /* wait until DMA2D transfer is done */
    while( TransferInProgress )
      ;

  #endif

#else

  /* wait until DMA2D transfer is done */
  HAL_DMA2D_PollForTransfer( &Accelerator, 1000 );
  TransferInProgress = 0;

#endif

  CPU_LOAD_SET_ACTIVE();
}

////////////////////////////////

My configuration is

static void SystemClock_Config( void )
{
  RCC_ClkInitTypeDef        RCC_ClkInitStruct;
  RCC_OscInitTypeDef        RCC_OscInitStruct;
  RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;

  /* Enable Power Control clock */
  __HAL_RCC_PWR_CLK_ENABLE();

  /* The voltage scaling allows optimizing the power consumption when the device is
     clocked below the maximum system frequency, to update the voltage scaling value
     regarding system frequency refer to product datasheet.  */
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  /* Enable HSE Oscillator and activate PLL with HSE as source */
  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;
#if defined(USE_STM32469I_DISCO_REVA)
  RCC_OscInitStruct.PLL.PLLM       = 25;
#else
  RCC_OscInitStruct.PLL.PLLM       = 8;
#endif /* USE_STM32469I_DISCO_REVA */
  RCC_OscInitStruct.PLL.PLLN       = 360;
  RCC_OscInitStruct.PLL.PLLP       = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ       = 7;
  RCC_OscInitStruct.PLL.PLLR       = 2;// connor
  HAL_RCC_OscConfig(&RCC_OscInitStruct);

  /* Activate the Over-Drive mode */
  HAL_PWREx_EnableOverDrive();
  /* Select PLLSAI output as USB clock source */
  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CK48;
  PeriphClkInitStruct.Clk48ClockSelection = RCC_CK48CLKSOURCE_PLLSAIP;
  PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
  PeriphClkInitStruct.PLLSAI.PLLSAIQ = 7;
  PeriphClkInitStruct.PLLSAI.PLLSAIP =RCC_PLLSAIP_DIV8;// RCC_PLLSAIP_DIV8;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct)  != HAL_OK)
  {
  
  }
  /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
     clocks dividers */
  RCC_ClkInitStruct.ClockType      = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
  RCC_ClkInitStruct.SYSCLKSource   = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider  = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);

  /* LCD clock configuration */
  memset( &PeriphClkInitStruct, 0, sizeof( PeriphClkInitStruct ));
  HAL_RCCEx_GetPeriphCLKConfig( &PeriphClkInitStruct );
  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;

#if EW_USE_DOUBLE_BUFFER == 1

  /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 MHz */
  /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 364 MHz */
  /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 364 MHz / 7 = 52.0 MHz */
  /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 52.0 / 2 = 26,0 MHz */
  /* These reduced LTDC clock frequency is neccessary to avoid display artefacts
     that occur on higher LTDC clock frequencies, if there is heavy memory access
     by application during display update */
  PeriphClkInitStruct.PLLSAI.PLLSAIN = 364;
  PeriphClkInitStruct.PLLSAI.PLLSAIR = 7;

#else

  /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 MHz */
  /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 417 MHz */
  /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 417 MHz / 5 = 83.4 MHz */
  /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 83.4 / 2 = 41.7 MHz */
  PeriphClkInitStruct.PLLSAI.PLLSAIN = 417;
  PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;

#endif

  PeriphClkInitStruct.PLLSAIDivR     = RCC_PLLSAIDIVR_2;
  HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
}

HAL Tick is this

uint32_t HAL_GetTick (void) {
  static uint32_t ticks = 0U;
         uint32_t i;

   HAL_IncTick();
  HAL_SYSTICK_IRQHandler();
 // if (osKernelGetState () == osKernelRunning) {
 //   return ((uint32_t)osKernelGetTickCount ());
 // }
  //If Kernel is not running wait approximately 1 ms then increment
   //  and return auxiliary tick counter value //
  for (i = (SystemCoreClock >> 15U); i > 0U; i--) {
    __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();
    __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();
  __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();
    __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();
 
  
  }
  return ++ticks;
}

Thanks

1 Answer

0 votes
by

Hi Connor,

difficult to provide you good help based on the code snippets.

The HAL_GetTick looks strange - usually the system tick is incremented by a timer driven system interrupt.

Is your software still based on the provided Build Environment for STM32F469 Discovery? Are there other modifications?

Which version of Embedded Wizard are you using? If you are using the latest version (currently 9.30) please post the complete console output.

If your hang up or the hardfault occurs randomly - it could be caused by other tasks. Can you ensure that no other tasks are accessing the GUI code?

Are you using DMA2D for other purposes in parallel to the GUI?

Best regards,

Manfred.

by

Hi Manfred,

Could you give me an example of HAL_GetTick

 

Thanks

by

Is there a need to re-implement HAL_GetTick? It is already implemented in stm32f4xx_hal.c.

The system tick (as well as Embedded Wizard tick and FreeRTOS tick) are incremented by the timer interrupt SysTick_Handler() in file /TargetSpecific/stm32f4xx_it.c.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...