forked from ksercan5/DRAM_Tester_Arduino
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update arduino.ino #1
Open
Stephen-Arsenault
wants to merge
2
commits into
main
Choose a base branch
from
adding-timers-to-read-write
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+39
−20
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
#define XA5 4 | ||
#define XA6 7 | ||
#define XA7 3 | ||
#define XA8 A6 | ||
#define XA8 14 | ||
|
||
#define M_TYPE 13 | ||
#define R_LED 12 | ||
|
@@ -38,6 +38,9 @@ | |
/* ================================================================== */ | ||
volatile int bus_size; | ||
|
||
int writeAverage = 0; | ||
int readAverage = 0; | ||
|
||
//SoftwareSerial USB(RXD, TXD); | ||
|
||
const unsigned int a_bus[BUS_SIZE] = { | ||
|
@@ -53,6 +56,7 @@ void setBus(unsigned int a) { | |
} | ||
|
||
void writeAddress(unsigned int r, unsigned int c, int v) { | ||
unsigned long startWrite = micros(); | ||
/* row */ | ||
setBus(r); | ||
digitalWrite(RAS, LOW); | ||
|
@@ -67,12 +71,20 @@ void writeAddress(unsigned int r, unsigned int c, int v) { | |
setBus(c); | ||
digitalWrite(CAS, LOW); | ||
|
||
unsigned int long currentTime = micros() - startWrite; | ||
|
||
digitalWrite(WE, HIGH); | ||
digitalWrite(CAS, HIGH); | ||
digitalWrite(RAS, HIGH); | ||
|
||
if (currentTime > 10000) { | ||
currentTime = writeAverage; | ||
} | ||
writeAverage = writeAverage == 0 ? currentTime : ((writeAverage + currentTime) / 2); | ||
} | ||
|
||
int readAddress(unsigned int r, unsigned int c) { | ||
unsigned long startRead = micros(); | ||
int ret = 0; | ||
|
||
/* row */ | ||
|
@@ -86,8 +98,15 @@ int readAddress(unsigned int r, unsigned int c) { | |
/* get current value */ | ||
ret = digitalRead(DO); | ||
|
||
unsigned int long currentTime = micros() - startRead; | ||
|
||
digitalWrite(CAS, HIGH); | ||
digitalWrite(RAS, HIGH); | ||
|
||
if (currentTime > 10000) { | ||
currentTime = readAverage; | ||
} | ||
readAverage = readAverage == 0 ? currentTime : ((readAverage + currentTime) / 2); | ||
|
||
return ret; | ||
} | ||
|
@@ -100,6 +119,7 @@ void error(int r, int c) | |
interrupts(); | ||
Serial.print(" FAILED $"); | ||
Serial.println(a, HEX); | ||
printStats(); | ||
Serial.flush(); | ||
while (1) | ||
; | ||
|
@@ -110,21 +130,13 @@ void ok(void) | |
digitalWrite(R_LED, HIGH); | ||
digitalWrite(G_LED, LOW); | ||
interrupts(); | ||
Serial.println(" OK!"); | ||
Serial.println(" DRAM Memory Passed "); | ||
printStats(); | ||
Serial.flush(); | ||
while (1) | ||
; | ||
} | ||
|
||
void blink(void) | ||
{ | ||
digitalWrite(G_LED, LOW); | ||
digitalWrite(R_LED, LOW); | ||
delay(1000); | ||
digitalWrite(R_LED, HIGH); | ||
digitalWrite(G_LED, HIGH); | ||
} | ||
|
||
void green(int v) { | ||
digitalWrite(G_LED, v); | ||
} | ||
|
@@ -141,7 +153,6 @@ void fill(int v) { | |
} | ||
g ^= 1; | ||
} | ||
blink(); | ||
} | ||
|
||
void fillx(int v) { | ||
|
@@ -157,18 +168,18 @@ void fillx(int v) { | |
} | ||
g ^= 1; | ||
} | ||
blink(); | ||
} | ||
|
||
void setup() { | ||
int i; | ||
|
||
delay(500); | ||
Serial.begin(9600); | ||
while (!Serial) | ||
; /* wait */ | ||
|
||
Serial.println(); | ||
Serial.print("DRAM TESTER "); | ||
Serial.print("DRAM TESTER Rev1: "); | ||
|
||
for (i = 0; i < BUS_SIZE; i++) | ||
pinMode(a_bus[i], OUTPUT); | ||
|
@@ -194,11 +205,11 @@ void setup() { | |
if (digitalRead(M_TYPE)) { | ||
/* jumper not set - 41256 */ | ||
bus_size = BUS_SIZE; | ||
Serial.print("256Kx1 "); | ||
Serial.println("256Kx1 "); | ||
} else { | ||
/* jumper set - 4164 */ | ||
bus_size = BUS_SIZE - 1; | ||
Serial.print("64Kx1 "); | ||
Serial.println("64Kx1 "); | ||
} | ||
Serial.flush(); | ||
|
||
|
@@ -214,10 +225,18 @@ void setup() { | |
digitalWrite(G_LED, HIGH); | ||
} | ||
|
||
void printStats() { | ||
Serial.println((String)"Columns — Read AVG: " + readAverage + " micros / Write AVG: "+writeAverage+" micros"); | ||
} | ||
|
||
void loop() { | ||
interrupts(); Serial.print("."); Serial.flush(); noInterrupts(); fillx(0); | ||
interrupts(); Serial.print("."); Serial.flush(); noInterrupts(); fillx(1); | ||
interrupts(); Serial.print("."); Serial.flush(); noInterrupts(); fill(0); | ||
interrupts(); Serial.print("."); Serial.flush(); noInterrupts(); fill(1); | ||
unsigned int long dramTimerStart = micros(); | ||
interrupts(); Serial.println("Test: Write \"0\" & Verify Read"); Serial.flush(); noInterrupts(); fillx(0); | ||
interrupts(); Serial.println("Test: Write \"1\" & Verify Read"); Serial.flush(); noInterrupts(); fillx(1); | ||
interrupts(); Serial.println("Test: Write \"0\" then \"1\" and Verify Read"); Serial.flush(); noInterrupts(); fill(0); | ||
interrupts(); Serial.println("Test: Write \"1\" then \"0\" and Verify Read"); Serial.flush(); noInterrupts(); fill(1); | ||
unsigned int long dramTimerStop = micros(); | ||
unsigned int long dramTimerDuration = dramTimerStop - dramTimerStart; | ||
interrupts(); Serial.println((String)"Total Test Duration: " + (dramTimerDuration / 1000) + " ms"); Serial.flush(); noInterrupts(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another example of math that could be slow? |
||
ok(); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the division here is inefficient? (just guessing)