SHARE
TWEET

NVRAM Programmer (M48Z02-150PC1)

a guest Apr 21st, 2012 1,988 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int prog_data[27] = {15,223,83,95,95,95,77,87,95,77,87,95,77,87,95,77,87,95,94,95,95,125,95,95,95,95,95};
  2. //int prog_data[27] = {222,222,222,222,222,222,222,206,222,222,94,142,222,94,174,222,210,222,222,222,222,222,222,222,220,222,222};
  3. //int prog_data[9]= {3,6,9,12,15,18,21,24,27};
  4. int addr_length = 27;
  5. int delayTime = 500;
  6. int redPin = 11;
  7. int greenPin = 12;
  8. int WritePin = 2;
  9. int DataPins[9] = {3,4,5,6,7,8,9,10,11};
  10. int AddrPins[6] = {A0,A1,A2,A3,A4,A5};
  11.  
  12. void setup(){
  13.   Serial.begin(9600);
  14.   pinMode(WritePin, OUTPUT);
  15.   pinMode(greenPin, OUTPUT);
  16.   pinMode(redPin, OUTPUT);
  17.   for(int derp = 0; derp <= 8; derp++){
  18.     pinMode(DataPins[derp], OUTPUT);
  19.   }
  20.   for(int durp = 0; durp <= 5; durp++){
  21.     pinMode(AddrPins[durp], OUTPUT);
  22.   }
  23.   digitalWrite(WritePin, HIGH);
  24.   stat(0);
  25. }
  26.  
  27. void loop(){
  28.   delay(2000);
  29.   stat(1);
  30.   for(int addr = 0; addr <=(addr_length-1); addr++){
  31.     Serial.println(addr);
  32.     output_addr(addr);
  33.     output_data(prog_data[addr]);
  34.     digitalWrite(WritePin, LOW);
  35.     delay(delayTime);
  36.     digitalWrite(WritePin, HIGH);
  37.   }
  38.   stat(0);
  39.   delay(3000);
  40. }
  41.  
  42.  
  43. void output_addr(int adr){
  44.   for(int lllama=4; lllama>=0; lllama--){
  45.     digitalWrite(AddrPins[lllama], (adr&1<<(4-lllama)?HIGH:LOW));
  46.   }
  47. }
  48.  
  49. void output_data(int dat){
  50.   for(int llama=7; llama>=0; llama--){
  51.     digitalWrite(DataPins[llama], (dat&1<<llama?HIGH:LOW));
  52.   }
  53. }
  54.  
  55. void stat(int state){
  56.   if(state==1){
  57.     digitalWrite(greenPin, LOW);
  58.     digitalWrite(redPin, HIGH);
  59.   }
  60.   else{
  61.     digitalWrite(greenPin, HIGH);
  62.     digitalWrite(redPin, LOW);
  63.   }
  64. }
RAW Paste Data
Top