cancel
Showing results for 
Search instead for 
Did you mean: 

I want to learn how to use registers - Is there any example collections of UART, ADC, PWM, Timers, DMA, CAN, SPI, I2C ect?

DMårt
Senior II

Hi!

I want to learn how to use registers by reading data sheet and write hex. I normally use CubeMX. But I think it's best for me to learn how it works under the hood.

To learn registers, I need to look at how other people have done so I can "copy" that knowledge to me.

I have done digital output and digital input projects with registers. Quite fun because you have control.

Do you know an example collection I can look at?

I'm using STM32F4 series.

6 REPLIES 6

You can find various parts and pieces on the net, but I know of no concise collection of examples. Mind, it requires some effort and time, and those who use register-level programming are usually professionals having bills to pay.

ST started Snippets for 'F0 and 'L0 and then they immediately cut it short in preference of the Cubes. You still can get some inspiration there as many peripherals are similar across the families (but not all - ADC and I2C stick out IIRC; DMA is quite different but in its basics also quite similar).

JW

So you recommend me to use CubeMX?

I'm not a professional and I'm not want to be any professional. Just to create things and make it works.

Daniel

Hi. Discover CubeMX examples. My path is C:\Users\AlexK\STM32Cube\Repository\STM32Cube_FW_F4_V1.24.1\Projects\STM32F4-Discovery\Examples.

They used HAL functions, but with some comments. You can find out something useful.

> So you recommend me to use CubeMX?

I don't know. This depends on where you see the fun factor - you've mentioned control, and for example that's why Cube/CubeMX is out of question for me. But you've also mentioned "create things" - and it is arguably easier to "create things" using Cube/CubeMX, or mbed, or any other prechewed "library" or "environment" or "platform" or whatnot.

Cube/CubeMX has its place, so has mbed, Arduino etc. Giving up control for comfort, and that's OK. There are professionals out there using it, and it's OK too. As long as they are content with its inherent and inevitable limitations and shortcomings - whether knowingly or not - they are go; as soon as they attempt to do something that was not envisaged by the "libraries" authors, they hit a wall. We see it here often. But then the same applies to barebones approach, when hitting limts of the chip itself. Except that the boundary is at a different place, and the programmer who goes for registers probably already has a good feeling where that boundary lies.

Documentation is erm... lacking for both cases. For Cube, you have some examples; I don't know how good are they to showcase CubeMX's usage, most of them were not created using CubeMX.

You always can try to "convert" examples from Cube to barebones, at least the simpler ones; Cube is open source even if it may be confusing and messy sometimes, but there are repetitive patterns. And you always can try yourself and come and ask here. You won't always receive a helpful answer.

Do you have a Disco?

JW

Yes, look at the Cube library sources, especially at "LL" (low level) variant rather then HAL.

That demonstrates a lot of registers usage,

-- pa

I want to create things fast and both learn how a MCU works.

I don't have a Disco. I'm have Nucleo.