然後編寫一個C文件,文件名tiny.c: #include <avr/io.h> #include <avr/eeprom.h>
int main() { DDRB |= _BV(4); //把PB4設置為輸出 PORTB |= _BV(4); //把PB4設置為高電平 eeprom_busy_wait(); eeprom_write_byte(0x00, 0xa5); eeprom_busy_wait(); eeprom_write_byte(0x01, 0xb6); eeprom_busy_wait(); eeprom_write_byte(0x02, 0xc7); eeprom_busy_wait(); eeprom_write_byte(0x03, PORTB); eeprom_busy_wait(); eeprom_write_byte(0x04, DDRB); eeprom_busy_wait(); eeprom_write_byte(0x05, PINB); eeprom_busy_wait(); while (1); } 為了方便起見,筆者是在Linux下用的avrdude+gccavr進行編譯的程序。在Windows平台上和WinAVR等價。用ICC AVR的話就得把頭文件改了,還要把_BV改成BIT。
|