I'm implementing a delay line and saving its buffer to SDRAM (starting from address 0xC0000000)
#define AUDIO_REC_START_ADDR (SDRAM_WRITE_READ_ADDR + SRAM_WRITE_READ_ADDR_OFFSET)
#define AUDIO_BUFFER_IN AUDIO_REC_START_ADDR
#define AUDIO_BUFFER_OUT (AUDIO_BUFFER_IN + (AUDIO_BLOCK_LENGTH * 2 * sizeof(q15_t)))
#define DELAY_BUFFER_START (AUDIO_BUFFER_OUT + (AUDIO_BLOCK_LENGTH * 2 * sizeof(q15_t)))
#define DELAY_MAX_SECONDS 1
#define DELAY_BUFFER_LENGTH (DEFAULT_AUDIO_IN_FREQ * 2 * DELAY_MAX_SECONDS) // stereo
If I write to the delay buffer in SDRAM and immediately read from it, the data is fine, but if I need to read from the buffer in following cicles of the main loop (as needed for the delay line) the data turns out to be corrupted.
What is the best way of storing data in SDRAM so that those locations are not overwritten?