Register names and C/C++ coding
Complete beginner into this world! Is it the name of the register that is used when coding? I have been looking through this Data Sheet: https://www.mouser.com/datasheet/2/268/70005303b-1108106.pdf and it says in different spots to set this bit to 1 to enable it or even to manipulate any bit since I assume that all generally works similarly. Some bit operation (bit clear, set, etc.), which I have done before, but I don't understand how to access the register to then get to that specific bit. I may have to do more reading, but I thought I would ask the question nonetheless so that I could maybe be carried into the correct direction.
Example: The table in page 126 and the register "GENCTRLn0"
Posted Jun 18, 2019, 6:59 PM UTC
The register names don't inherently mean anything to your compiler. All of those peripheral registers (not core CPU registers) have addresses that will be listed in the datasheet or reference manual. The vendor will usually (always?) provide a C header file at least that has macros for the registers, and maybe a hardware abstraction layer that simplifies manipulating them. You can create your own header file if you want, or if none is provided.
The header entries will look something like this:
So now RCM is a macro that refers to a register at 0x4007F000. You could rename it RESET_CONTROL_MODULE if you wanted and it wouldn't make any difference, as long as the address is right.
That's definitely what I thought! Since, from my limited experience of 1 microcontroller course, we worked with header files and "macros". I have scoured several parts of the datasheet and had not found the register addresses, so I became skeptical that the names may mean something. How is the C header file or HAL usually provided? Are they usually available online for anyone to view, or is it somehow provided with a bought microcontroller?
If they have an example project for that MCU you could find it in there most likely
They should be available online usually, or for more obscure/high volume stuff you might have to contact the vendor. And then sometimes it's just obscure. For example, with NXP you'll get lost forever if you try to just navigate through their site in the most logical manner. It'll take a little digging to find out that the only way to get those files now is to create an account on their SDK builder site and select the particular part you're after and the options you want, and it'll build a whole package with the (craptastic) documentation, drivers, and header files.