Skip to content

Commit 3213dfa

Browse files
committed
Update bit range setting comment
1 parent 2399f99 commit 3213dfa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ By setting individual bits, we can selectively set specific pins to a desired
160160
mode. For example, this snippet sets pin A3 to output mode:
161161

162162
```c
163-
* (volatile uint32_t *) (0x40020000 + 0) &= ~(3 << 6); // CLear bits 6-7
164-
* (volatile uint32_t *) (0x40020000 + 0) |= 1 << 6; // Set bits 6-7 to 1
163+
* (volatile uint32_t *) (0x40020000 + 0) &= ~(3 << 6); // CLear bit range 6-7
164+
* (volatile uint32_t *) (0x40020000 + 0) |= 1 << 6; // Set bit range 6-7 to 1
165165
```
166166

167167
Let me explain those bit operations. Our goal is to set bits 6-7, which are
@@ -209,8 +209,8 @@ Now, it should be clear to you, dear reader, the meaning of these two lines,
209209
which set bits 6-7 of the GPIOA MODER register to the value of 1 (output).
210210

211211
```c
212-
* (volatile uint32_t *) (0x40020000 + 0) &= ~(3 << 6); // CLear bits 6-7
213-
* (volatile uint32_t *) (0x40020000 + 0) |= 1 << 6; // Set bits 6-7 to 1
212+
* (volatile uint32_t *) (0x40020000 + 0) &= ~(3 << 6); // CLear bit range 6-7
213+
* (volatile uint32_t *) (0x40020000 + 0) |= 1 << 6; // Set bit range 6-7 to 1
214214
```
215215

216216
Some registers are not mapped to the MCU peripherals, but they are mapped to
@@ -225,8 +225,8 @@ register by direct accessing certain memory addresses. Let's look at the
225225
snippet that sets pin A3 to output mode:
226226

227227
```c
228-
* (volatile uint32_t *) (0x40020000 + 0) &= ~(3 << 6); // CLear bits 6-7
229-
* (volatile uint32_t *) (0x40020000 + 0) |= 1 << 6; // Set bits 6-7 to 1
228+
* (volatile uint32_t *) (0x40020000 + 0) &= ~(3 << 6); // CLear bit range 6-7
229+
* (volatile uint32_t *) (0x40020000 + 0) |= 1 << 6; // Set bit range 6-7 to 1
230230
```
231231

232232
That is pretty cryptic. Without extensive comments, such code would be quite

0 commit comments

Comments
 (0)