I have some IMU setup, but tried this one with Bosch BMI160. I'm normally reading using only blocking functions, so ex. to read X, Y and Z I'll write_read 7 bytes (first byte of MISO buffer will be dummy then). But now tried with one byte blocking write for command and DMA to read data, nothing happens as well beside just single one read fired with correct data after some long seconds of waiting. You can try that approach with full DMA data harvesting (for me it's working):
Here 'data_0' is a start register of IMU data, and there are 23 bytes of data to read into 'data' buffer. First will be a dummy byte, so you can mask it out with a pointer or sth to start from 0 if you need it. But mixing blocking and DMA SPI works for me just fine when driving SD card.
PS. Im using spi1 for that IMU as well if it might be an issue here.
PS2. SD is also on spi1 - different setup.
Code:
dma_channel_configure(dma_tx, &c_tx, &spi_get_hw(SPI)->dr, data_0, 24, false);dma_channel_configure(dma_rx, &c_rx, data, &spi_get_hw(SPI)->dr, 24, false);dma_channel_wait_for_finish_blocking(dma_rx);dma_start_channel_mask((1u << dma_tx) | (1u << dma_rx));
Here 'data_0' is a start register of IMU data, and there are 23 bytes of data to read into 'data' buffer. First will be a dummy byte, so you can mask it out with a pointer or sth to start from 0 if you need it. But mixing blocking and DMA SPI works for me just fine when driving SD card.
PS. Im using spi1 for that IMU as well if it might be an issue here.
PS2. SD is also on spi1 - different setup.
Statistics: Posted by MatSOBDev2 — Wed Jul 31, 2024 3:12 pm