cancel
Showing results for 
Search instead for 
Did you mean: 

Baud Rate problem

fiulala
Associate II
Posted on July 09, 2015 at 17:15

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
4 REPLIES 4
Posted on July 09, 2015 at 19:14

Can someone help me please? 

Why can't you use the standard code within SystemInit() and system_stm32f4xx.c to set up the clocks and PLL properly?

Make sure it's using the HSE clock, and that it's clocking properly at 8 MHz. You're using the STM32F4-DISCO right? Or something else?

Output the HSE and PLL clocks using the PA8 (MCO) pin, and measure them with a scope.

If you're not using an 8 MHz HSE, then make sure the HSE_VALUE define reflects the actual clock rate you're using.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
fiulala
Associate II
Posted on July 10, 2015 at 16:04

Thank you for reply. Yes, I'm using stm32f4 discovery. Now I'm confused... with the previous code i get the properly clock at the timers. I read PA6 in a scope and i got exactly 40 kHz.

Now I configured clock and PLL in SystemInit() and system_stm32f4xx.c as you said. I configured HSE_VALUE at 8MHz, PLL_M 5, PLL_N 210, PLL_P 2, AHB prescaler 1, APB1 prescaler 4 and APB2 prescaler 2. I should get CPU at 168 MHz, APB2 at 84 and APB1 at 42. But now the timers doesn't clock properly!! Now I read in PA6 7,58 kHz frequency instead of 40 kHz.

What's going on?

Posted on July 10, 2015 at 16:40

What's going on?

Ultimately I think you're best placed to figure that out.

RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
printf(''SYS:%d H:%d, P1:%d, P2:%d

'',
RCC_Clocks.SYSCLK_Frequency,
RCC_Clocks.HCLK_Frequency, // AHB
RCC_Clocks.PCLK1_Frequency, // APB1
RCC_Clocks.PCLK2_Frequency); // APB2

You could use the APB clocks, as the system deciphers it's internal configurations, instead of using SystemCoreClock.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
fiulala
Associate II
Posted on July 10, 2015 at 17:18

Output:

168000000

168000000

42000000

84000000

I don't know really what happened but now the timers work and I get from USART the correct data. Thank you very much