4
\$\begingroup\$

I am working with an ARM Cortex M3 chip (reference manual available here). I'm trying to get the baud rate of my USART communications right. Reading pages 613 onwards, I understand that the value I should set for USARTDIV depends on the clock rate of AHB1 (since I am working with USART3, governed by the AHB1 clock).

Looking at pages 614 onwards, I see that the clock rate f_PCLK can take many different values (8MHz, 12Mhz, etc.). However, I cannot see anywhere where I can set the speed of that clock.

How can I measure/change/read the speak of the AHB1 clock?

\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

Page 83 of the reference manual has a clock tree diagram. This will help you see where the clocks come from.

The PCLK is a peripheral clock and will depend on the clock source and the prescaler values. The AHB, APB and other prescaler values are set in the system_stm32f2xx.c file.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks! Do you understand what the line __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; exactly means? \$\endgroup\$
    – Randomblue
    Commented Mar 20, 2012 at 16:20
  • \$\begingroup\$ It's an array that is used to set the SystemCoreClock variable. Search for both AHBPrescTable and SystemCoreClock and you should be able to figure out what's going on. \$\endgroup\$
    – Armandas
    Commented Mar 20, 2012 at 16:29
  • \$\begingroup\$ @Armandas, I know this is an ancient topic, but could you describe how AHBPrescTable is indexed, I'm finding the code impenetrable. Thanks! \$\endgroup\$ Commented Oct 17, 2019 at 11:24
  • \$\begingroup\$ @RichardWhitehead I don't get your question. What do you mean by "indexed"? \$\endgroup\$
    – Armandas
    Commented Oct 18, 2019 at 2:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.