discovery
discovery copied to clipboard
RTRM question
On this page, https://docs.rust-embedded.org/discovery/07-registers/rtrm.html is this statement:
We are interested in the register that's at an offset of 0x18 from the base address of the GPIOE peripheral. According to the table, that would be the register BSRR.
Why are we interested in this offset? How does one conclude that this is the correct offset / register for our use? I've RTRM's a lot and cannot find an obvious connection.
@jamesmunns
I'm planning on working on some PRs that will hopefully alleviate these types of questions, as I agree with the one redditor who said that is seems like the book "skipped a chapter." I have come up with the following high-level plan, to allow for early feedback for those who are curious.
1.) Add more to "Meet Your Hardware" to better explain how the microcontroller and board differ and interact.
Reasoning: This will hopefully make it more apparent that we are a.) programming the microcontroller, which itself is b.) changing how the pins are operating. These pins are connected to the board in such a way that they can c.) drive the LEDs on the board. This context seems to be assumed, so explicitly setting it out should be helpful for Chapter 7, when registers and GPIO pins are introduced in more detail.
2.) Simplify the introduction to chapter 7, restricting it to just the new code, a quick description of what the code does, and a promise that we'll explain how it works over the course of the chapter.
Reasoning: Currently, the intro tries to explain some of the code in a few paragraphs, with some quick text on registers/addresses. This makes it seem like that is all the tutorial is going to talk about how the code works. The "But how can one find out what this register does?" line is in a spot that is easy to miss between the end of the pin-driving aside and the end of the page, which might add to the confusion.
3.) In chapter 7, go a bit more into detail on memory mapping and registers. This will explain what a register is, why we need to access it through memory address, and generally set up the idea that in order to do anything with the LEDs we need to manipulate registers in a specific way.
Reasoning: I feel it's important to ensure developers understand that even though 0x12345678
and 0x87654321
look like they both access "memory" (in the "heap and stack" paradigm), they might be accessing completely different types of devices. Section 7.3 (0xBAAD address
) talks about this a bit, but I feel we've already lost some people by then.
4.) Much more explanation on how the author was able to determine all the info needed to drive the LED through the BSRR register in the "RTRM" section.
Reasoning: Currently, we write that we found specific information on a specific page of a reference manual, but little about WHY we looked at that page to begin with. That is the knowledge that is needed in order to complete the next chapter's challenge, so it's important to explain it.
@markhildreth I totally agree with your plan, and wanted to thank you again for writing these up! Let me know if there is anything I can do to help, and I'll try to keep all of your PRs reviewed as quickly as possible!