-
Notifications
You must be signed in to change notification settings - Fork 11
/
Arduino-DRAM-tester.ino
182 lines (138 loc) · 3.27 KB
/
Arduino-DRAM-tester.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// -*- C -*-
/* Simple DRAM tester
* Chris Osborn <[email protected]>
* http://insentricity.com/a.cl/252
*
* Status LED is on while testing and blinks after each pass
* Done LED will flash after all four passes
* Status and Done LEDs will be ON after all tests pass
* Status OFF and Done ON means testing failed
*
* TODO:
* - Rolling bit pattern to test for failed address lines
* - Test 4 bit nibble mode
* - Test read-modify-write
* - Test RAS-only refresh
* - Test CAS-before-RAS
* - Test limits of refresh time (8ms)
* - Fast testing using TF pin
*/
#define DIN 2
#define DOUT 3
#define CAS 5
#define RAS 6
#define WE 7
#define STATUS 4
#define DONE 19
#define ADDR_BITS 10
void fillSame(int val);
void fillAlternating(int start);
void setup()
{
int mask;
pinMode(DIN, OUTPUT);
pinMode(DOUT, INPUT);
pinMode(CAS, OUTPUT);
pinMode(RAS, OUTPUT);
pinMode(WE, OUTPUT);
/* 10 is max address bits, even if chip is smaller */
mask = (1 << 10) - 1;
DDRB = mask & 0x3f;
mask >>= 6;
DDRC = mask & 0x0f;
digitalWrite(CAS, HIGH);
digitalWrite(RAS, HIGH);
digitalWrite(WE, HIGH);
pinMode(STATUS, OUTPUT);
pinMode(DONE, OUTPUT);
digitalWrite(STATUS, HIGH);
digitalWrite(DONE, LOW);
}
void loop()
{
int i;
fillSame(0);
digitalWrite(STATUS, LOW);
delay(250);
digitalWrite(STATUS, HIGH);
fillSame(1);
digitalWrite(STATUS, LOW);
delay(250);
digitalWrite(STATUS, HIGH);
fillAlternating(0);
digitalWrite(STATUS, LOW);
delay(250);
digitalWrite(STATUS, HIGH);
fillAlternating(1);
digitalWrite(STATUS, LOW);
delay(250);
digitalWrite(STATUS, HIGH);
for (i = 4; i; i--) {
digitalWrite(DONE, HIGH);
delay(500);
digitalWrite(DONE, LOW);
delay(500);
}
digitalWrite(DONE, HIGH);
}
static inline int setAddress(int row, int col, int wrt)
{
int val = 0;
PORTB = row & 0x3f;
PORTC = (PORTC & 0xf0) | (row >> 6) & 0x0f;
digitalWrite(RAS, LOW);
if (wrt)
digitalWrite(WE, LOW);
PORTB = col & 0x3f;
PORTC = (PORTC & 0xf0) | (col >> 6) & 0x0f;
digitalWrite(CAS, LOW);
if (wrt)
digitalWrite(WE, HIGH);
else
val = digitalRead(DOUT);
digitalWrite(CAS, HIGH);
digitalWrite(RAS, HIGH);
return val;
}
void fail(int row, int col)
{
digitalWrite(STATUS, LOW);
digitalWrite(DONE, HIGH);
while (1)
;
}
void fillSame(int val)
{
int row, col;
digitalWrite(DIN, val);
for (col = 0; col < (1 << ADDR_BITS); col++)
for (row = 0; row < (1 << ADDR_BITS); row++)
setAddress(row, col, 1);
/* Reverse DIN in case DOUT is floating */
digitalWrite(DIN, !val);
for (col = 0; col < (1 << ADDR_BITS); col++)
for (row = 0; row < (1 << ADDR_BITS); row++)
if (setAddress(row, col, 0) != val)
fail(row, col);
return;
}
void fillAlternating(int start)
{
int row, col, i;
i = start;
for (col = 0; col < (1 << ADDR_BITS); col++) {
for (row = 0; row < (1 << ADDR_BITS); row++) {
digitalWrite(DIN, i);
i = !i;
setAddress(row, col, 1);
}
}
for (col = 0; col < (1 << ADDR_BITS); col++) {
for (row = 0; row < (1 << ADDR_BITS); row++) {
if (setAddress(row, col, 0) != i)
fail(row, col);
i = !i;
}
}
return;
}