; ************************************************ ; 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 .NOLIST .INCLUDE "C:\avrtools\appnotes\8515def.inc" .LIST ; Registers .def mp = R16 ; Multi-Purpose .def soll = R17 ; AA and 55 ; Reset-/Interrupt-Vector rjmp main ; Main program main: ldi mp,LOW(RAMEND) ;Initiate Stackpointer out SPL,mp ; for the use with subroutines ldi mp,HIGH(RAMEND) out SPH,mp ; Port B is driver for the LEDs ldi mp,0xFF ; All outputs out DDRB,mp ; to data direction register Port B 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 AAh for test loop: inc XL ; Increment 16-bit adress counter by 1 brne check ; No carry to MSB inc XH ; Increment MSB breq check ; MSB overroll, end check: st X,soll ; write Bit pattern to SRAM ld mp,X ; Read the same SRAM-Adress cp mp,soll ; compare written and read brne Zurueck ; Not equal, skip further tests com soll ; Invert bit pattern (XOR FF) st X,soll ; Test again with 0101.0101=55h ld mp,X ; Read cp mp,soll ; Compare brne Zurueck ; Not equal, skip further testing com soll ; invert test pattern again rjmp loop ; Go on with next location Zurueck: ld mp,-X ; Drecrement Pointer X, Result in mp doesn't matter Ungleich: com XH ; XOR FF of the highest RAM-Adress out PORTB,XH ; to the LEDs ende: rjmp ende ; Loop for ever