Answer the question
In order to leave comments, you need to log in
How to properly process a circular buffer in C (stm32)?
Good day everyone!
There is a device based on the stm32 microcontroller that polls the ADC and adds the results via DMA to the ring buffer: __IO uint32_t buff[4096];
when half the buffer and the whole buffer are full, interrupts are called in which you need to overtake the corresponding half of this array to the SD card via SPI (8bit). How can you access half of an array and iterate over it byte by byte?
as long as it comes to mind
void SPI1_send(unsigned char cmd);
for (i=0;i<2048;i++) {
SPI1_send(buff[i]>>24);
SPI1_send(buff[i]>>16);
SPI1_send(buff[i]>>8);
SPI1_send(buff[i]);
}
Answer the question
In order to leave comments, you need to log in
unsigned char* ptr = (unsigned char*)&buff[2048]; - something like this. Get a pointer to half the buffer and it will be of type char, and you just need addressing by bytes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question