Wednesday, September 21, 2022
Galin Engine
Monday, May 31, 2021
STM32 Synchronizing Clocks
Problem Statement:
You have two (or more) STM32 Nucleo boards, and need their clocks to be synchronized. This means, that we allow for a non-zero phase offset between the clocks, but the phase offset should not change with time.
One way to confirm this is that viewing the clock outputs for the two boards on your scope, triggering off one waveform should freeze the other clock waveform too.
Solution:
1. Setting up the clock on the MASTER board:
a) within STM32CubeMX navigate to the "System Core" -> RCC tab and set the LSE clock source to "Crystal/Ceramic Resonator". Also, check the "Master Clock Output" checkbox. Doing this will send the clock to the MCO pin on the board (usually GPIO pin PA8). You will then connect that pin on the MASTER board to the CN7pin29 on the SLAVE board. See figure 1 for an example.
Note: The MCO pin likely automatically be configured as "Alternate Function Push Pull", however, in addition, you will need to set the maximum output speed for this pin to "High" (the default is "Low").
b) open STM32CubeMX for your slave board, and navigate to the "Clock Configuration" tab to see the acceptable external HSE input frequency range. Then locate the "MCO Source Mux" in STM32CubeMX of the MASTER board and select the MCO frequency to be within this range (usually 1 - 32 MHz). See figure 2 for an example clock configuration on the MASTER board.
c) program the board. Hook up a scope MCO output (GPIO pin PA8) of the MASTER board, and confirm that you get a clock signal of the appropriate frequency. See figure 3.
2. Setting up the clock on the SLAVE board (the same configuration may be repeated on other slave boards):
a) refer to the User Manual for your board and understand what board configuration is required to configure the external high-speed clock (HSE) pins to accept input from an external oscillator through pin CN7pin29 (i.e. PF0 pin). In my case both boards are MB1136, and suggested configuration on page 24 is shown in figure 4.
Note: Make sure to get the correct manual; look up the MB number at the back of the Nucleo board and get the manual for that numbered board. In my case the MB number for both boards is MB1136, and hence this is the appropriate manual.
b) within STM32CubeMX navigate to the "System Core" -> RCC tab and set both HSE/LSE clock sources to "BYPASS Clock Source", see figure 2. Checking the "Master Clock Output" checkbox is not necessary, but will help verify that you have in fact synchronized the clocks at the end of this exercise.
Note: The Master Clock Output (MCO) is usually output to GPIO pin PA8 on most (but not all STM32) boards. This GPIO pin will automatically be configured as "Alternate Function Push Pull" but in order to see an output on the scope the maximum output speed for this pin should be set to "High" (the default is "Low").
c) figure 5 provides the clock diagram for the slave board. Program the board.
3. Putting it all together:
a) connect the MCO output of the MASTER board (GPIO pin PA8, CN12pin23) to the expected HSE clock input pin on the SLAVE board (GPIO pin PF0, CN11pin29).
b) connect a scope to the MCO outputs on both the MASTER and SLAVE boards to confirm that the clocks are in sync. See figure 6.
Tuesday, December 18, 2012
Running
I guess it is to be expected to write a blog post about "life and everything", ponder the meaning 'of it all', and reflect on the year past at a time when the calendar year is changing.
The water glistening green and blue, and softly gurgling as it hugs the roots of trees and rocks. The submerged sand scalloped by the repeated return of waves. The air is still, the trees only occasionally rustle with the lazy wind.
"Carpe diem" and/or "Live in the moment"; oft quoted words to encourage people to dig deep for the courage to feel alive everyday. Words meant to encourage a sense of wonder and that nose tingling excitement about the world around you - I'm feeling it now. But also, for myself, a sentiment that I do not understand. Taken at face value, it's quite a stressful idea. Don't relax 'into it', concentrate, ask yourself, 'are you really living the moment?'. But wait, it's gone, try again. Okay. Oh...there it goes, lost, that moment, slipping like sand through your fingers... How do you enjoy holding sand? When all you can do is concentrate on how to keep it in your hands for longer? You know it'll all be gone anyway.
You stop. Your breath is heavy, rasping your throat, your pulse quick and your whole body feels it - the quickened rhythm of your heart. Your are alone, and you let yourself relax into the sounds around you, filled with the chatter of birds, energetic screeching of parrots, the resonant hum of cicadas.
I've recently come to realise that "carpe diem" just isn't for me. My life is full, and as it slips through my hands, I enjoy and study it as it cascades onwards. I look back and appreciate what I see, it's not easy, and why would it be?
The final leg of your run is a menacing hill. You see the car at the top, small and far away. You put your head down, and concentrate on attempting to enjoy the burning in your legs. The only way to the top is one step at a time. You'll get there, but damn it, you wonder why the hell you parked so far away :)
Sunday, November 4, 2012
GUILTY GENERATION
*****
Why do we (should we) care about climate change?
Because climate change is no longer just affecting our climate system, but through peoples efforts it is having an effect on our thinking, society, our markets, policy, economics, and industry. Sadly constantly the phrase rings out – I ‘believe’ in climate change, I do not ‘believe’ in climate change. I hope we share the desire not to believe (or not) in climate change, but because as we see its far-reaching influence, we want to ‘know’ more about it.
But I find that there’s not a lot of clarity out there on this issue. More specifically, clarity on how we are affecting it, and how we will be affected by it. This isn’t exactly clear to me. If we take to one side the question about whether humans are affecting the climate or not, and consider a message that has received some traction – that of reducing your energy consumption, or your ‘green footprint’ you get an overwhelming amount of questions:
Don’t you print double-sided? Don’t you drive a Prius? Don’t you recycle? Don’t you switch the lights off when you leave the room? Don’t you unplug your mobile phone charger? Don’t you avoid using the elevator?
We are: 'THE GUILTY GENERATION’.
'Back in the good ol’ days' people were optimistic about the future. It seems like a foreign sentiment to feel these days. Optimism about the future is unheard of in a general humanitarian sense. Sure, you can be optimistic about your future SAT scores, or your new baby etc, but about the future of mankind in general - well that's blasphemy really, and/or you just haven't been watching the news. They (i.e. our parents, and theirs) thought that by now we’d be on Mars, teleport all over the place, live forever, looking like Elle McPherson. There was excitement, optimism, things where being built, people where looking forward to the future…
Not anymore.
We, the future of the past are made to feel guilty all the time. Is that fish you’re eating? Is it from a sustainable source? But what is sustainable? (I have this awesome app on my phone: http://www.sustainableseafood.org.au/Sustainable-Seafood-Guide-Australia.asp?active_page_id=695) Do you recycle your plastics? But did you know that packaging companies might finance recycling centers, and encouraging consumerism (http://www.forbes.com/sites/amywestervelt/2012/04/25/can-recycling-be-bad-for-the-environment/)? How is it that it may costs less to buy a new TV than to have your old one repaired? How much do cows really fart – and how is it really affecting the climate? (this is kinda cute: http://www.show.me.uk/site/news/STO873.html)
I don’t think I deserve to, or that we need to.
I think the reason I become susceptible to this external guilt is that I do not understand the problem(s) entirely. I don’t know how large it is, and I don’t actually know how I contribute to it. This cloudiness leads to lack of action, to the point of apathy on my part. I think the key is in quantifying this issue, i.e. putting it in a context, and removing ambiguity always helps – for example, very simplistically, price is usually a first indicator we use to judge quality: How do I know if a bottle of wine is better than another? I look at the price. (For me £100 is always worse than a £5 bottle....especially for mulled wine... :))
So in my search for clarity, I stumbled across a text that addressed the issue of sustainable energy objectively. It got down to the numbers and quantified the situation. It’s called “Sustainable Energy: without the hot air” by David Mackay (http://www.withouthotair.com/).
This in my opinion is a text that addresses the issue (ahem…guilt) of sustainable energy (conveniently for those of you in the UK, in a British context) in a quantitative way, fanning away adjectives, and replacing them with numbers. It removes the guilty feeling, because it quantifies the problem. It answers questions about how big this problem really is, how you can affect it as an individual. By putting the issue of sustainable energy in a current quantitative context it becomes tractable.
Seriously. The message? Let’s stop to this guilt, by making a directed/informed choice.
Saturday, October 6, 2012
Saturday mornings
Thursday, October 4, 2012
Scheherazade
Tell me about the dream where we pull the bodies out of the lake
and dress them in warm clothes again.
How it was late, and no one could sleep, the horses running
until they forget that they are horses.
It’s not like a tree where the roots have to end somewhere,
it’s more like a song on a policeman’s radio,
how we rolled up the carpet so we could dance, and the days
were bright red, and every time we kissed there was another apple
to slice into pieces.
Look at the light through the windowpane. That means it’s noon, that means
we’re inconsolable.
Tell me how all this, and love too, will ruin us.
These, our bodies, possessed by light.
Tell me we’ll never get used to it.
-Richard Siken
Thursday, September 13, 2012
What is it that we miss?
...and sometimes I remember people who are so dear to me, but with whom I can never create new memories. I miss them. I miss their voice, their hugs and warmth. Their thoughts. Sometimes this makes me think that I am a very selfish person. I miss them because I gained so much from them. Being with them made me happy, and doing things for them made me happy. Sharing my life with them made me happy, and playing a part in theirs.
Recently a dear friend passed away, and I am sad.
Now you can no longer change me, and I can no longer affect you. But I won't forget that you made me a better person and how grateful I am that you cared. I will keep you with me.
"I will always miss you."