2019-08-05 10:58 AM
I'd like to know if there are any resources that say "to set up the DMA to transfer data from the ADC to a memory location, these steps must be completed" or "to set up PWM output on a pin, these steps must be completed"
These are two examples of things I've "gotten to work" by following examples and via CubeMX, but it all feels very trial and error, and blind. Where / how does one learn what is strictly necessary to achieve configuration of the STM32 peripherals? The various reference manuals seem to be the most useful in this regard, but I'd especially love some pointers as to how to figure out exactly the intended uses of the LL and HAL libraries are.
2019-08-05 01:25 PM
As a general rule the horse goes in front of the cart.
The Reference Manual is a good start, but there is probably some inferred knowledge in sequences. There's some expectation college level classes on this sort of stuff covers orders/precedence and some grasp of how all the assorted parts come together in a micro-controller or SoC expression of systems from olden days.
The example code tends to the be closest thing to a check-list, or paint-by-numbers methodology, as it was typically coded by someone familiar with the inner-workings of the IC or the engineers involved. Pay attention to block diagrams, these might illustrate connectivity and plumbing that might not be clear from descriptions provided in the prose.
The libraries frequently have block descriptions in the front describing how routines work together, and how different modes using different groups of functions, or where they are dependent on interrupts/callbacks etc.
The registers, or surrounding descriptions, may flag or highlight is something must be disabled or enabled, but these things can also be subtle.
Synchronous logic needs a clock, clocks need to be on before you can program the registers. Pins need to be configured before you use them.
DMA controllers need to have addresses/size configured before you enable a transfer.
The SPI/USART lock the baud registers once enabled, make sure all pending data is transmitted before stopping and changing rates.
You can not change the settings on an active PLL, so you have to switch the system to a different clock, and disable the PLL to change the settings. After starting you must wait for it to lock, and then select it as the new source.
You need to select slower FLASH wait states before switching to the faster clock source.
Any situation where unpredictable results might occur, best to disable the connectivity/functionality first.