2018-05-04 11:36 AM
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 #prescaler2018-05-04 11:48 AM
>>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?
2018-05-05 02:11 AM
Yes, that's correct, it HardFaults.
How can I debug this?
2018-05-05 01:46 PM
I'd start by using a handler that outputs information so that I can identify the specific instructions which are causing the fault.
2018-05-05 02:00 PM
thank you, I'll have a look