Direct Register Access notes

Configuring the MCU all works with registers. You set values to the different registers and that configures the system clock, timer modes, GPIO functions, which peripherals have their clock enable, GPIO states, etc, etc.

Direct register programming, which is straight up writing a value to a register, creates much faster execution time for the MCU to run than using any kind of API or library.

Problem is it takes much more time for the programmer to create code only in direct register access, especially with more complex tasks like controlling a LCD or USB applications.

Direct register access has also no fail safes. You can do whatever you want. If you get a register wrong or a value wrong, there will not be any error from the compiler at all.

So direct register access is only advised in 2 situations.

  • There isn't a function that does what you want so you just have the option do direct access.

  • You have a vital piece of code that is time critical so you need to use direct access to save execution time.~

So since sometimes you really need to use it and it's good to know how your MCU works inside let's see a bit about registers.