cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect internal clock signal

sebastien2399
Associate II
Posted on October 22, 2015 at 15:17

Hello !!!

I would recover my internal clock signal (configure to 16MHz)  with  an oscilloscope when I switch a pin of my microcontroller the signal is only of 450khz. Could someone explain to me why I don't  exceed the 450khz ?

my main program :

int main(void)

{

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

  HAL_Init();

  /* Configure the system clock */

  SystemClock_Config();

  /* Initialize all configured peripherals */

  MX_GPIO_Init();

  while (1)

  {

    HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_5);

  }

}

Thank you in advance and sorry for my poor english .

#stm32 #clock
3 REPLIES 3
Posted on October 22, 2015 at 15:23

The function to toggle is taking 35-36 machine cycles?

You'd want to confirm the internal clocks using the PA8 (MCO) signal.

You don't specify which STM32 you're using, which might effect the bus the GPIO peripheral is on.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sebastien2399
Associate II
Posted on October 22, 2015 at 15:34

I'm use a STM32l051K6

carl2399
Associate II
Posted on October 23, 2015 at 03:28

It's only a short function. Generate the extended assembly listing, and have a look though it. As Clive has already indicated, you'll probably find the inner loop is around 35 instructions long.

There's always something to be learned from how various coding styles translate into what gets generated by the compiler. You'll then start to gather the tools you need when you really need to optimise some code for speed - short of writing the code at the assembly language level.

Also try the same at different optimiser settings. Optimise for speed. Optimise for size. Don't optimise at all. Look at the generated assembly.

Regard,

Carl.