Guest User

Untitled

a guest
Aug 19th, 2017
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define A19 9
  2. #define A18 16
  3. #define A17 17
  4. #define A16 48
  5. #define A15 1
  6. #define A14 2
  7. #define A13 3
  8. #define A12 4
  9. #define A11 5
  10. #define A10 6
  11. #define A9 7
  12. #define A8 8
  13. #define A7 18
  14. #define A6 19
  15. #define A5 20
  16. #define A4 21
  17. #define A3 22
  18. #define A2 23
  19. #define A1 24
  20. #define A0 25
  21. #define AA1 45
  22.  
  23. #define WE 11
  24. #define RESET 12
  25. #define BUSY 15
  26. #define BYTE 47
  27.  
  28. #define DQ0 29
  29. #define DQ1 31
  30. #define DQ2 33
  31. #define DQ3 35
  32. #define DQ4 38
  33. #define DQ5 40
  34. #define DQ6 42
  35. #define DQ7 44
  36.  
  37. #define OE 28
  38. #define CE 26
  39.  
  40.  
  41. long address = 0;
  42. uint8_t inputs[8] = {DQ0,DQ1,DQ2,DQ3,DQ4,DQ5,DQ6,DQ7};
  43. uint8_t adress[21] = {AA1, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19};
  44.  
  45.  
  46. void setup() {
  47.   for(int i=1; i<=48; i++)
  48.     pinMode(i, OUTPUT);
  49.   pinMode(BUSY, INPUT_PULLUP);
  50.   for(int i=29; i<=44; i++)
  51.     pinMode(i, INPUT);
  52.  
  53.   digitalWrite(BYTE, LOW);
  54.   digitalWrite(WE, HIGH);
  55.   digitalWrite(RESET, HIGH);
  56.   digitalWrite(OE, LOW);
  57.   digitalWrite(CE, LOW);
  58.  
  59.   Serial.begin(9600); // Chaning this changes the byte values
  60.   delay(5000);
  61. }
  62.  
  63. void loop() {
  64.   byte reading = 0;
  65.   address++;
  66.   if (address == 16000000)
  67.     while(1)
  68.       delay(1); // Stop everything when max address is reached
  69.      
  70.   Serial.print(address);
  71.  
  72.   for (uint8_t i = 0; i < 21; i++)
  73.     digitalWrite(adress[i], bitRead(address, i));
  74.  
  75.   Serial.print(":"); // This should be enough for the 70 ns access time
  76.   //delay(1); // Adding this for example changes the byte values
  77.  
  78.   for (uint8_t i = 0; i < 8; i++)
  79.     reading |= digitalRead(inputs[i]) << i;
  80.  
  81.   Serial.println(reading,HEX);
  82. }
RAW Paste Data