I don't know if this is the right place to post this, but i was wondering if someone could create a library out of this file for me, every time I try it never works. I made a program to read/write to a RAM chip with 8 addresses pins and 4 I/O pins, the one defined in the integers is the AM9111.
You may change anything including the voids and integers if it will make it easier.
Here is the code:
int addr[] = {0,1,2,3,4,5,6,7}; //address pins
int od = 12; //Output Disable pin; to read, must be low
int we = 13; //Write Enable pin(in this case on inverted write enable); to write must be low
int io[] = {8,9,10,11}; // Input/Output pins
// ^LSB ^MSB
int ios[] = {0,0,0,0}; //I/O Storage, used to store arduio arduino input bits
void w(int b0, int b1, int b2, int b3) //Write to RAM
{
pinMode(io[0],OUTPUT);
pinMode(io[1],OUTPUT);
pinMode(io[2],OUTPUT);
pinMode(io[3],OUTPUT);
digitalWrite(od,1);
digitalWrite(we,0);
delay(2); //give the chip time
digitalWrite(io[0],b0);//<-|
digitalWrite(io[1],b1);// | set address values
digitalWrite(io[2],b2);// |
digitalWrite(io[3],b3);//<-|
delay(2); //give the chip time
digitalWrite(we,1);
digitalWrite(od,0);
}
void addrSet(int a0,int a1,int a2,int a3,int a4,int a5,int a6,int a7) //Set address on RAM
{
digitalWrite(addr[0],a0);//<-|
digitalWrite(addr[1],a1);// |
digitalWrite(addr[2],a2);// |
digitalWrite(addr[3],a3);// |set address to write/read to/from
digitalWrite(addr[4],a4);// |
digitalWrite(addr[5],a5);// |
digitalWrite(addr[6],a6);// |
digitalWrite(addr[7],a7);//<-|
delay(5); //give chip time
}
void r() //read from I/O on RAM
{
pinMode(io[0],INPUT);
pinMode(io[1],INPUT);
pinMode(io[2],INPUT);
pinMode(io[3],INPUT);
delay(100);
ios[0] = digitalRead(io[0]);
ios[1] = digitalRead(io[1]);
ios[2] = digitalRead(io[2]);
ios[3] = digitalRead(io[3]);
}
void serialTrans()
{
Serial.print("---->\n");
Serial.print(ios[0]);
Serial.print(ios[1]);
Serial.print(ios[2]);
Serial.print(ios[3]);
Serial.print("\n---->\n");
}
void setup()
{
Serial.begin(9600);
digitalWrite(od,0);
digitalWrite(we,1);
}
void loop() {}
Thanks in advance.
RAM.pde (1.73 KB)