cancel
Showing results for 
Search instead for 
Did you mean: 

STM8 HSE

ACogl
Associate III

Hi,

I am testing an application, and currently is working properly with HSI configured to 16MHz.

Now I want to enable the HSE.

I am using a NUCLEO-8S208RB. I have soldered an external crystal on X2, and i have configured the board with 12pF capacitors and 0 ohms resistor.

The crystal has a resonance frequency of 24 MHz. Configuring the firmware in order to output the clock frequency from pin 57 of STM8S (CLK_CCO), everything seems working (i can see the 24MHz synusoid with the oscilloscope).

Unfortunately the microcontroller is not working, because the application doesn't run.

I have configured the HSE clock in this way:

CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);

CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);

  

/* Output Fcpu on CLK_CCO pin */

CLK_CCOConfig(CLK_OUTPUT_CPU);

/*Enable external oscillator*/

CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

CLK_HSECmd(ENABLE); //I have some doubts about this...is it really needed?

Do you see anything wrong?

Best regards

1 ACCEPTED SOLUTION

Accepted Solutions
ACogl
Associate III

​I have managed to solve this problem: in the datasheet (DocID14733 Rev 13 page 49), in the Option bytes section it is written that in order to use an HSE with a frequency higher than 16MHz you need to put the option byte WAITSTATE to 1 (OPT7).

View solution in original post

1 REPLY 1
ACogl
Associate III

​I have managed to solve this problem: in the datasheet (DocID14733 Rev 13 page 49), in the Option bytes section it is written that in order to use an HSE with a frequency higher than 16MHz you need to put the option byte WAITSTATE to 1 (OPT7).