Using Arduino as EPROM emulator

Hi all,

I've got an issue I'm trying to figure out. I have an array of bytes in PROGMEM that I am trying to access by toggling pins and reading the pins that I have set up as data pins - as if it were EPROM. It's SORT OF working, but it always starts by giving me the last byte, first. I can't figure out why, but if I tell it to show me byte 0 of the array, it shows the correct byte. The array is 4KByte in size (0x00-0xFFF), and it always shows me the byte at 0xFFF first before the correct data, and then that byte again every 511 bytes before the correct data.

Am I writing this wrong? Any help would be appreciated!

while (1){
    //check that we've got a stable address
    while ((address = ADDRESS_IN) != address_prev){
      address_prev = address;
    }
    //if address 12 = 1
    if(address & 0x1000){     
      //grab a byte from that address and send to data port
      PORTD  = ((uint8_t)byteArray[address & 0xFFF]);
      dataOut();
      
      //wait for the address to change
      while(ADDRESS_IN == address);      
      dataIn();
    }
  }

Curious…
The first test will return [true or false] as a result of the = assignment, but that’s being compared (!=) with address_prev ??

Both the address and address_prev variables start at 0, so the idea is that the current address on the pins is compared to the previously checked address until they are both the same value. This is just to make sure the address coming from my other controller are stable before assuming a read is being done.

Me too, you hide too many details.

Please post your full code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.