-
Great! I'll start the first discussion! But I noticed that my solution differed from yours in one significant detail... I called
would have implicitly read the AHBENR register and only manipulated the IOPEEN bit. I notice that you called When/why should I use the --wpd |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for starting the first discussion! The read/modify/write methods are documented on svd2rust, but the gist is:
So, whenever you only want to change a few fields, you have to use In the book's case, it's fine to use Later, if you're just changing a single pin, using |
Beta Was this translation helpful? Give feedback.
Thanks for starting the first discussion!
The read/modify/write methods are documented on svd2rust, but the gist is:
write()
starts from the register's reset value (which might not be zero), then changes just the fields you specify, and writes the resultmodify()
starts with a read of the register, then changes the fields you specify and writes the resultwrite_with_zero()
starts from 0, changes your fields, writes.So, whenever you only want to change a few fields, you have to use
modify()
, otherwise you'll wipe out any changes to the other fields.In the book's case, it's fine to use
write()
since we are happy to set all the other pins (0-7) to 0 and just turn on 8-15.…