2020-08-17 11:30 PM
Using the library functions the micro freezes and enters a CLK assert, this is the code I use to configure the CLK:
CLK_DeInit ();
CLK_HSECmd (DISABLE);
CLK_LSICmd (DISABLE);
CLK_HSICmd (ENABLE);
while (! CLK_GetFlagStatus (CLK_FLAG_HSIRDY));
CLK_ClockSwitchCmd (ENABLE);
CLK_HSIPrescalerConfig (CLK_PRESCALER_HSIDIV1);
CLK_SYSCLKConfig (CLK_PRESCALER_CPUDIV1);
CLK_ClockSwitchConfig (CLK_SWITCHMODE_AUTO,
CLK_SOURCE_HSI,
DISABLE,
CLK_CURRENTCLOCKSTATE_ENABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_SPI, DISABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_I2C, DISABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_ADC, DISABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_AWU, DISABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_UART1, DISABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_TIMER1, DISABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_TIMER2, DISABLE);
CLK_PeripheralClockConfig (CLK_PERIPHERAL_TIMER4, DISABLE);
When I just change the divider of the CLK_HSIPrescaler or CLK_SYSCLKConfig everything works but at a lower frequency than desired.
Would you know how to do the right configuration to make it run at 16Mhz?
All the parameters of the datasheet are respected, use of the STVD with the Cosmic Compiler 8. Windows 7 operating system. The test project is attached to this question.
Thanks in advance to ST community.
2020-09-29 02:11 AM
I solved this after adding a 100nF filter to every power source pin of the micro-controller I'm now capable of use the micro at 16Mhz internal clock speed.
I was using all the components listed on the datasheet, but somehow filtering the power source near the microcontroller make it works.