6 years, 11 months ago.

How to change system clock?

Hi everyone,

I have a nucleo F767ZI board. I mounted an external 8 Mhz crystal to the board and I want to change system clock. The thing is that I can not see the c code for system clock configurations. When I create a new project, mbed configurations comes with folder which does not have any replaceable content.

There might be a simple way but I could not figure it out.

If you're using mbed-os2 then import the mbed-dev library. This has the sourcecode you can modify for selecting a different clock source. If you're using mbed-os5 then you need to look at the instructions on here for forking a version of the mbed-os code from github and importing it. Both have ST's original sourcecode in it.

posted by Bill Bellis 15 May 2017

1 Answer

6 years, 11 months ago.

Hi. I was writing a lengthy reply to your baud rate question using alternate external clock values but found that mbed does offer support for low level register reading and writing that will be helpful. Curious to know why you would mount a 8 Mhz external crystal since the board is already being clocked @ 8 Mhz through the MCO trace and SB149.

Reference pg 74

http://www.st.com/content/ccc/resource/technical/document/user_manual/group0/26/49/90/2e/33/0d/4a/da/DM00244518/files/DM00244518.pdf/jcr:content/translations/en.DM00244518.pdf

See here on ideas on how to alter or read the required registers (see code from Wim and Kamil):

https://developer.mbed.org/questions/54029/USART-Problem-with-NucleoF401RE/

From our understanding, you should be able to take the same 8 Mhz factory clock source -> apply required PLL values to increase the UART clock so you can increase the baud rates for your project.

How are the boards interconnected ? Straight wires or will you use RS422 or RS485 transceivers ?

Any length of wiring at these high baud rates is not recommended unless you insert external transceivers like RS422 (point to point) or RS485 (multiple nodes can listen and then respond of indexed = multidrop). Check Maxim and others for suitable examples of transceivers. If your wiring is very far from each then you must consider galvanic isolation for the same transceivers. Check Analog, Linear for such options. Adafruit may have some of these parts pre-mounted for experiments. Isolation is necessary if there is a chance for ground potential differences between one side of the wiring to the other.

The baud rate (USART) values are directly linked to your CPU and internal PLL values. So if you increase these values, your baud rate will also increase.

A good article worth reviewing but using a different compiler:

http://www.carminenoviello.com/2015/03/02/how-to-use-stm32-nucleo-serial-port/