1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

avrでsram

Last updated at Posted at 2018-02-28

概要

avrでsramやってみた。
attiny85でアセンブラで書いた。
attiny85には、512byteのsramがある。

環境

avr studio 4
attiny85 1mhz
tera term
usb-serial

写真

image

サンプルコード

sramの先頭から255→1まで、書き込んで読んでみる。

setup:
    ldi     r16, high(RAMEND)
    out     SPH, r16
    ldi     r16, low(RAMEND)
    out     SPL, r16
    cbi     DDRB, PB0
    sbi     DDRB, PB1
    sbi     PORTB, PB1
loop:
    ldi     ZL, LOW(SRAM_START)
    ldi     ZH, HIGH(SRAM_START)
    ldi     r22, 255
    st      Z+, r22
    dec     r22
    brne    PC - 2
    ldi     ZL, LOW(SRAM_START)
    ldi     ZH, HIGH(SRAM_START)
    ldi     r22, 255
    ld      r16, Z+
    rcall   bin2hex2
    ldi     r19, ' '
    rcall   send
    dec     r22
    brne    PC - 5
    rcall   wait
    rjmp    loop

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?