C???????MCU?????????????
?????????????????SFR????SRAM???????????SRAM???????C?????????????????????????????????
1????????C??????????????????????
??????C?????????????????????????MCU????????????:
#define DDRB (*(volatile unsigned char *)0x25)
?????????
A??(unsigned char *)0x25?е?0x25???????????(unsigned char *)???0x25?????????????????????洢?????????????????unsigned char????????????/д??????????д??unsigned char????????????unsigned char?????
(*(volatile unsigned char *)0x25)???????????????????????????????????????????"*"????*(volatile unsigned char *)0x25?????????(?????unsigned char????????????????)???????#define i (*(volatile unsigned char *)0x25),????unsigned char i????????????????i?????ǹ?????
B:?????volatile?????????????C?????????????????????????????????????????while(*(unsigned char *)0x25)??????????????????????0x25??????????????ζ??????????????????????????????????????????volatile???????ζ????0x25????????
??????/д??0x25??????SRAM??????????дDDRB???????DDRB????????????????????????0x25?????磺
DDRB = 0xff;
???????????????????????????????????磺
unsigned char *p, i;
p = 0x25;
i = *p; //?????0x25????е????????????i????
*p = 0; //?????0x25??????д??0
???????????(*(volatile unsigned char *)0x25)?????????????????????????????????????????0x25????0x25????????????????????????????
2????C????????????????
??C????????????????????MCS51???KeilC??????sfr???????????????
sfr P0 = 0x80;
????????0x80??????дP0???ɡ?
?????AVR???C???????????MCU?????????????м?顣
A:??????C?????????????????????????MCU????????????C????????????????????????C??
B:ICCAVR??GCCAVR??ж???????????????????????C?????????????????????????MCU??????????IAR??CodeVisionAVR????????ANSI C????????????????????????????????C?????????????MCU???й??????????磬IAR?У?
SFR_B(DDRB, 0x28)
CodeVisionAVR?У?
sfrb DDRB = 0x28
????,PORTB=0xff;?????(*(volatile unsigned char *)0x05) = 0xff;??0x25??????????PORTB??????ATmega48/88/168?е?????
GCCAVR???AVR????????????????????????????????????????iomx8.h?????????????????
#define PORTB _SFR_IO8(0x25)
????sfr_defs.h?п?????????????????壺
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr)+0x20)
#define _MMIO_BYTE(mem_addr) (*(volatile unit8_t *)(mem_addr))
????????????????????????????????????
????GCCAVR?к?_BV(bit)?????I/O????????????????avr-libc??????????????м??????λ?????????????sfr_defs.h?ж????????
#define _BV(bit) (1<<(bit))
????????????????;
DDRB = _BV(PB0) | _BV(PB1); //?????????????????PB0????0??PB1????1
???????“DDRB=0x03;”,????д??????????????????????????????????????“DDRB=0x03;”?????????????????????????飬??????????“DDRB=0x03;”?????????

????admin ?????????2018-05-19