2015-10-22 06:17 AM
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 #clock2015-10-22 06:23 AM
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.2015-10-22 06:34 AM
I'm use a STM32l051K6
2015-10-22 06:28 PM
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.