Appendix 3: Debugging Tale
BYTE
_BYT
x05) + 0x20)
olatile uint8_t *)((0x05) + 0x20))
(*(vol
gh
(volat
#define _SFR_IO8(io_addr) MMIO ((io_addr) + 0x20)
Goody, we already know what _MMIO E is so we can do substitutions:
PORTB is _SFR_IO8(0x05)
_SFR_IO8(0x05) is _MMIO_BYTE((0
_MMIO_BYTE((0x05) + 0x20) is (*(v
yields:
(((volatile uint8_t )(((uint16_t) &( atile uint8_t *)((0x05) + 0x20)))) ))
|= (1 << (5)))
What we wrote was:
sbi(PORTB, 5); // set OC1A hi
What the compiler sees is:
(((volatile uint8_t )(((uint16_t) &(( ile uint8_t )((0x05) + 0x20)))) )) |=
(1 << (5)))
Aren’t you glad you aren’t a compiler?