cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030CCT crashes when AHB prescaler is 8 or higher

dtpnilsson
Associate II
Posted on May 04, 2018 at 20:36

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

#low-power #ahb #clock #prescaler
4 REPLIES 4
Posted on May 04, 2018 at 20:48

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

I'm confused about what that actually means.

If you stop it in the debugger where is it?

Does in enter the HardFault_Handler, or Error_Handler, or some other while(1) loop going nowhere?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 05, 2018 at 09:11

Yes, that's correct, it HardFaults.

How can I debug this?

Posted on May 05, 2018 at 20:46

I'd start by using a handler that outputs information so that I can identify the specific instructions which are causing the fault.

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 05, 2018 at 21:00

thank you, I'll have a look