AnsweredAssumed Answered

STM32F030CCT crashes when AHB prescaler is 8 or higher

Question asked by nilsson.daniel.003 on May 4, 2018
Latest reply on May 5, 2018 by nilsson.daniel.003

When trying to set up RCC as the following using Cube, the microcontroller seems to crash.

 

      RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV8; 

 

I checked that the RCC_SYSCKL_DIV8 macros (and higher options) actually correspond to bits stated in datasheet.

How do I make the micro run at a slower clock using the AHB prescaler?

 

 

 

The full init as generated by Cube:

 

void SystemClock_Config(void)
{

 

  RCC_OscInitTypeDef RCC_OscInitStruct;
  RCC_ClkInitTypeDef RCC_ClkInitStruct;

 

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = 16;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

 

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV8;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    Error_Handler();
  }

 

  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

 

  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

 

  /* SysTick_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}

 

 

 

 

thanks,

Daniel

Outcomes