2025-08-23 11:41 PM
I am trying to make a guitar loop pedal with my nucleo-l476rg board. It has 1MB of flash and I am trying to write and read from bank 2 only as it is the bank of memory I want to use for storing recorded audio. I currently have an active buffer set up between my ADC and DAC and it works well. My goal is to continue to have this active passthrough while recording and playing. It currently stays active when recording however, my DAC shuts off or I read on open circuit from my multimeter when I press the play button. I believe my issue is with either how I am writing to FLASH memory or reading from it. I am using two buffers to achieve this active passthrough while recording as one buffer stores samples while the other is being written to memory and then the buffers reverse. This buffering I believe is working properly as I've been testing which code is running with the on-board LED however i dont think memory part of my code is working. I am coding this at the register level. I've attached my main file. Any help would be greatly appreciated.
2025-08-24 6:25 AM
for(uint32_t x=0;x<1024;x+=2){
// uint32_t word = ((uint32_t)BackBuffer[x+1]<<16)|(uint32_t)BackBuffer[x];
*(volatile uint32_t *)(addr) = BackBuffer[x];
while(FLASH->SR & FLASH_SR_BSY);
FLASH->SR |= FLASH_SR_EOP;
addr += 2;
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5, GPIO_PIN_SET); //LED on if playing
}
You're writing 4 bytes (uint32_t), then you're skipping ahead only 2 bytes and writing again. This is not allowed. You must write exactly 2 uint32_t to an aligned address. This is also not writing every value. Your commented code is better but needs to skip ahead 4 bytes, not 2.