I have an ISR that reads values from a byte array that is loaded from the main program loop. The main loop only writes to the array; the ISR only reads from it, never writes. Is it still necessary to use the volatile keyword? I ask because the array is passed by pointer to the SD card reading function that actually fills the buffer, but one (apparently) cannot cast a volatile byte* to a byte* or even a volatile byte* to a void*.
I've considered using an intermediate buffer and memcpy(), but would rather avoid the extra clock cycles this would require.
Background: I'm working on a program that reads data from an SD card and outputs it to several pins at 20-30 kHz. I have enough time to do this (I think, I haven't tested reading with the ISR running yet). The buffer is larger than a block on the SD card, so the SD reading can load one part of the buffer while the ISR reads from another. I can't post actual code since I'm not at that machine, but the basic structure is this: loop: Check flag for load status in part of buffer. If read, fill it with new data, and set flag appropriately. ISR: Read the next set of values from the buffer, output them. If we crossed a "block boundary" in the buffer, set a flag indicating the previous block is now empty.
Thanks for any help, or nudges toward reading that'll help.