I have an array uint8_t data[256]. But each element is single byte.
My data bus is 32 bit long. So, If I want to access 32 bits, I do:
DATA = data[i] + (data[i + 1] << 8) + (data[i + 2] << 16) + (data[i + 3] << 24);
But this translates into 4 separate read requests in the memory of one byte each.
How can I access all the 4 bytes in the form of single transaction?
datais of typeint [256], not only one byte is read for each summand.int data[256];be composed of single-bytes. The 'bytes' would have to be at least 16 bits each (CHAR_BIT == 16). There is some confusion in the assumptions you're making, I think. If, as one of your comments suggests, you meanuint8_t data[256];, then one question is 'are you going to index at values ofithat are not multiples of 4'? and another question is 'what happens if you try to access an 'improperly aligned' memory address as a 4-byte unit?' You need to know the answers to both before risking short-cuts.