2017-09-07 12:43 PM
I am using STM32CubeMX 4.22.0
I am using STM32F103C8T6 chip with Keil v5 under Windows 10.I configured only RCC to
HSE for Crystal\Ceramic Resonator and in Clock Configuration input frequency to 8 MHz and HCLK to 72MHz .I generated the code for keil, but at the function 'SystemClock_Config()' the chip falls into Error_Handler().
following code was generated:
void SystemClock_Config(void)
{RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;/**Initializes the CPU, AHB and APB busses clocks
*/ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }I debug step by step. At the point 'Error_Handler' the program goes in to infinite loop of function 'Error_Handler(char * file, int line) ' I can not understand what is the problem. I also attached the full project at the attachment.
#stm32cubemx-4.22-systemclock_config-bug*2017-09-08 01:06 AM
And does your external clock actually start and function?
2017-09-08 11:41 AM
Thanks for Reply,
I have not tested the code on real hardware. I have debugged the code in Keil Simulator(Debugger). the program has been going in to infinite loop of 'Error_Handler' during the SystemClock_Config() .
2017-09-08 12:23 PM
Hello!
Your code is working fine in my cheap ebay board with f103c8t6
Try to increase the timeout of ''HSE clock ready'' like this
If you put eg 5000 and you have the same error.. the oscillator is problematic(crystal capacitors resistors)
Actually the 100ms are very enough to start the HSE!
2017-09-08 03:24 PM
Very very thanks for your replay,
I tried HSE Startup timeout Values to 100, 200 and 500; But same error occurred. May be this error has
occurred due to software debugging.
As you suggested, I shall try this code (with adding a led blink) on myboard with STM32F103c8t6 (Blue Pill).
2017-09-08 07:02 PM
The simulator probably isn't going to work well referencing external hardware.
2017-09-08 08:10 PM
Hello!
The simulator , for sure is not going to work. it is tested .
In my pevious post i missed the word 'not' inside 'I have not tested the code on real hardware'
2017-09-09 03:30 AM
Thank you for your valuable suggestions.
The code is working fine in my blue pill board; but not in keil simulator, I tested. Thank you for your valuable suggestions.
It is sure that there is no meaning of software debugging in keill. Is there any simulator available for stm microcontroller ?
2017-09-09 03:35 AM
Thanks for your reply.
I tested this code in external hardware, It is running fine.
2017-09-09 04:34 AM
hi!
If you don't want flashing and regflashing your MCU, you have the option to run the program from RAM for debuging
The Keil's simulator is a very good simulator for ARM MCUs (code without involving peripherals only) but for peripherals.. not How can simulate an incomming byte from UART or an EXTI event or in your case the HSE_RDY flag?