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();
}
}