ATtiny13 >> Assembly

LED


DDRB(I/O方向)、PORTB(I/O輸出)


main.s

  .equ PINB,  0x16
  .equ DDRB,  0x17
  .equ PORTB, 0x18
 
  .org 0x0000
  rjmp main
 
  .org 0x0010
main:
  sbi DDRB, 1
 
loop:
  sbi PORTB, 1
  rcall delay
  cbi PORTB, 1
  rcall delay
  rjmp loop
 
delay:
  ldi r24, 0xff
  ldi r25, 0x80
d0:
  sbiw r24, 1
  brne d0
  ret

編譯和燒錄

$ avr-as -mmcu=attiny13 -o main.o main.s
$ avr-ld -o main.elf main.o
$ avr-objcopy --output-target=ihex main.elf main.ihex
$ sudo avrdude -c usbasp -p t13 -B 1024 -U flash:w:main.ihex:i
  avrdude: set SCK frequency to 500 Hz
  avrdude: AVR device initialized and ready to accept instructions

  Reading | ################################################## | 100% 0.20s

  avrdude: Device signature = 0x1e9007 (probably t13)
  avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
           To disable this feature, specify the -D option.
  avrdude: erasing chip
  avrdude: set SCK frequency to 500 Hz
  avrdude: reading input file "main.ihex"
  avrdude: writing flash (38 bytes):

  Writing | ################################################## | 100% 4.51s

  avrdude: 38 bytes of flash written
  avrdude: verifying flash memory against main.ihex:
  avrdude: load data flash data from input file main.ihex:
  avrdude: input file main.ihex contains 38 bytes
  avrdude: reading on-chip flash data:

  Reading | ################################################## | 100% 4.26s

  avrdude: verifying ...
  avrdude: 38 bytes of flash verified

  avrdude: safemode: Fuses OK (E:FF, H:FF, L:6A)

  avrdude done.  Thank you.

完成


返回上一頁