Path: Home => AVR-Overview => Hardware => RAM    (Diese Seite in Deutsch: Flag DE) Logo

; TestRam tests external SRAM on the STK-200 board

; ************************************************
; TestRam tests external SRAM on the STK200 board
; Counts SRAM-positions by writing AAh and 55h
; in each position, verifies the content and displays
; the MSB of the highest SRAM-adress on the LEDs.
; ************************************************

; Explanation on the RAM access
; The MUX-IC 74HC573 and the SRAM 62256-70 have to be
; installed on the board.
; Port A is multiplexed adress bus for the LSB adress and the
; data bus
; Port C is the upper adress bus
; Port D Bit 6 is /RD (Read) on the SRAM, Bit 7 is /WR (Write)
; Line ALE (Adress Latch Enable) is used, Pin 30 of the 8515
; If the whole external SRAM has been tested ok, all LEDs are
; switched on except LED7. The highest adress then is
; 7FFFh, if a 32 kB SRAM is used.

; 8515-definitions


; Registers

.def   mp = R16 ; Multi-Purpose
.def   soll = R17 ; AA or 55 for test

; Reset-/Interrupt-Vector

   RJMP   main

; Main program

main:   LDI   mp,LOW(RAMEND) ;Initiate Stackpointer
   OUT   SPL,mp ; for subroutines
   OUT   SPH,mp

; Port B drives the LEDs

   LDI   mp,0xFF ; All outputs
   OUT   DDRB,mp ; to data direction register

   IN   mp,MCUCR ; Read MCU-Control-Register
   ORI   mp,0x80 ; Set Bit 7
   OUT   MCUCR,mp
; If the SRAM used is slower than 70 ns and therefore requires an
; additional WAIT-state, then Bit 6 has to set additionally. The
; ORI command then must be ORI mp,0xC0 to set bit 6, too.

   LDI   XL,LOW(RAMEND) ; Register XL is R26, LSB RAM-Adress
   LDI   XH,HIGH(RAMEND) ; Register XH is R27, MSB RAM-Adress

   LDI   soll,0b10101010 ; Bit pattern for Test

   INC   XL
; Inc adress
   BRNE   check ; Not zero, MSB ok
   INC   XH ; Inc MSB of Adress
   BREQ   check ; Zero, MSB overflow, skip
   ST   X,soll
; write Bitpattern to SRAM
   LD   mp,X ; Read the same location
   CP   mp,soll ; Compare written and read
   BRNE   Zurueck ; Not equal, skip
   COM   soll ; Invert bit pattern (XOR FF)
   ST   X,soll ; write 0101.0101
   LD   mp,X ; Read back
   CP   mp,soll ; compare
   BRNE   Zurueck ; Not equal, skip
   COM   soll ; invert
   RJMP   loop ; next location

   LD   mp,-X
; Decrement Pointer X
   COM   XH
   OUT   PORTB,XH ; to the LEDs
ende:   RJMP   ende ; Loop forever

©2002 by