Appendix 3: Debugging Tale
ow we can speculate that uint8_t is a char. I say speculate because going further
wo
guess t
figure tion can be quite dense.
Let
_M O pointer to a volatile
cha o
Backing up a bit we look at the _SFR
_M O t is
a _SFR_ADDR?
#de e
Which nd:
#define _SFR_MEM_ADDR(sfr) ((uint16_t) &(sfr))
o
e had: _SFR_BYTE(sfr)
which is and alias for: _MMIO_BYTE(_SFR_ADDR(sfr))
the _ SFR_ADDR aliased _MMIO_BYTE(_SFR_MEM_ADDR(sfr))
that aliased _MMIO_BYTE( ((uint16_t) &(sfr)) )
and _MMIO_BYTE aliased ((volatile uint8_t )( ((uint16_t) &(sfr)) ))
which we can substitute for the _SFR_BYTE(sfr) in the sbi macro
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
N
uld require poking around in the gcc compiler stuff, and I’d rather live with my
han suffer that. Anyway, I’ve already lost track of what I was trying to
out in the first place. All theses layers of decep
’s state what we found.
MI _BYTE is a macro that declares mem_addr to be a
r p inter. I’m getting scared, how about you?
_BYTE macro and see that it provides
MI _BYTE with a mem_addr of the type _SFR_ADDR. Oh, bother. Wha
Well, in sfr_defs.h we find:
fin _SFR_ADDR(sfr) _SFR_MEM_ADDR(sfr)
do n’t help so we look for _SFR_MEM_es ADDR and fi
We now know that _SFR_ADDR is an alias for _SFR_MEM_ADDR which is
macro to declare sfr as a uint16_t, and we’ll guess that’s a 16 bit integer. What the
heck is the & for? Let’s do some substitutions. If you remember we were trying t
understand the meaning of the sbi macro and it had _SFR_BYTE(sfr) in it so:
W