2024-10-10 07:11 AM - last edited on 2024-10-10 08:15 AM by SofLit
Hi, I am trying to program a STM32L552ZEQ to use HSE instead of the default clock, but I am doing something wrong.
I attach the reference manual, as well as the user manual for my specific board. In the user manual, on page 24, it is stated that there is a HSE with 16 MHz clock frequency. I try to enable this by setting the HSEBYP and HSEON bits in `RCC->CR`, like so
```
```
Using GDB I observe the change to the register value happening as expected. After setting it, I am waiting for the hardware to set the HSERDY bit, indicating that everything went OK. But this bit is never set. I never seem to get out of this while-loop. I observe the bit not being set using e.g. GDB.
I looked at the reference manual and saw that MCO is fed to OSC_IN, which seems correct.
I then thought that it appears as if the MCO can be connected to several different sources, one of which being the HSE. I look at the reference manual, and find this
I modify my code to configure MCOSEL to have the value `0100`, to indicate that we should output the HSE to the MCO pin. I am using the CMSIS header files to access the correct addresses, and it seems as if the define for MCOSEL_2 carries the right value (4).
```
// the define is in the CMSIS header-file, but I paste it here for clarity
Solved! Go to Solution.
2024-10-10 08:26 AM
ST does not connect the MCO on some Nucleos such as L4 and L5, likely to allow lowest possible power consumption.
2024-10-10 09:45 AM
I am sure that I can find a colleague at work to help me solder. I can see the empty hole for PH0, e.g., but it is not clear to me from reading the user manual from where I can fetch ST-LINK MCO. What physical modifications do I need to do? I would love to learn how I can decode this from the two documents.
Thanks,
Robert
2024-10-10 09:58 AM - edited 2024-10-10 10:01 AM
@krook wrote:it is not clear to me from reading the user manual from where I can fetch ST-LINK MCO. What physical modifications do I need to do?
From the extract @Chris21 posted, these are the settings you need:
"Off" means that there is no connection across the solder bridge - the bridge is open;
"On" means that there is a connection across the solder bridge - the bridge is closed.
(look like they forgot that this is just a solder bridge and not a jumper link - where the jumper would be literally on the pins, or off them)
PS:
https://community.st.com/t5/stm32-mcus-products/docmentation-of-solder-bridges/m-p/689362
2024-10-10 10:24 AM
Where ST's default SB is On, you will find a zero ohm resistor across the bridge; these can be a little annoying to remove unless you have good soldering equipment / skills.
Here they say to remove SB142, but it looks like that may not really be necessary.
2024-10-11 01:02 AM
It is much clearer now, these two last comments made it clearer what exactly solder bridges are. I can now also see on page five of the user manual that there is a description of this, but it was a bit too concise for me to make a meaning out of it.
I am primarily a software developer, but your short and concise comments made it clearer. Looking at my board (to verify what is written in the document), it indeed appears as if the configuration is not correct to do what I want.
I gather that if I manage to move the resistor from SB142 to SB143, the hardware should be correctly configured, and I can access the clock by manipulating registers, i.e through software.
2024-10-11 07:45 AM
I've made the necessary changes, and turn on SB143 while I've turned off SB142. However, I must have done something wrong as the HSERDY bit still never is set. Hopefully the error now is simply a software error. The code I am using to try and use the ST-LINK MCO follows
```
```
Here is a picture of my modified board
Any idea what my likely error is now? I can't remember what, but something gave me the impression that the ST-LINK MCO would appear as HSE. @Andrew Neil @Chris21
2024-10-11 08:45 AM
It looks like you have done the correct things with the hardware and software.
I wonder about R19 on the ST-LINK:
It looks like that would need to be present.
2024-10-12 07:07 AM
@Chris21, that does indeed seem relevant. May I ask where you found this diagram? For my own future reference in trying to figure these things out.
When I look at my board, there is indeed what I interpret as an OFF solder bridge there. I believe that I should put another 0-Ohm resistor there to make the current be able to pass. This was less obvious to me as R19 was not mentioned in the two documents I looked in. It makes sense that this detail should be found in the ST-LINK documentation, but I only considered that my STM-board was misconfigured.
Thanks,
Robert
2024-10-12 07:10 AM
I misclicked and accepted an answer while I was trying to figure out how to edit my comment above (let's hope that R19 is the only missing piece of this puzzle, and that that answer is indeed the correct one!).
I was going to add a question, what does 100R mean? It is stated next to R19 in the diagram @Chris21
2024-10-14 07:38 AM
The schematic for the board is on ST's web site: https://www.st.com/en/evaluation-tools/nucleo-l552ze-q.html, click on the CAD resources tab.
100R denotes a 100 ohm resistor, but 0 ohms (or a bit of solder) should work.
Did you check with an oscilloscope to see if there's a clock signal at SB143?