Hi,
I'm having trouble with configuration of SPI_Master_DMA driver on SAMV70. I'm using ASF4 with Atmel Start.
I have successfully configured SPI_Master_Sync driver, but it's going too slow (4MHz despite being configured for 12MHz plus about 2.75us additional delay between every 2-3 bits).
I tried switching to SPI_Master_DMA, but after trying to send first byte, it always immediately calls me back over SPI_M_DMA_CB_ERROR (status variable in XDMAC_Handler has XDMAC_CIS_WBEIS flag set).
SPI_0: https://snipboard.io/ze2uEa.jpg
XDMAC: https://snipboard.io/KGtCag.jpg
clocks: https://snipboard.io/muq68I.jpg
Code snippet:
static volatile bool transferDone; static void txcb(struct _dma_resource *resource) { (void)resource; transferDone = true; } static void txerr(struct _dma_resource *resource) { (void)resource; transferDone = true; // <-- immediately goes here } static void send_byte(uint8_t b) { spi_m_dma_get_io_descriptor(&SPI_0, &io); spi_m_dma_register_callback(&SPI_0, SPI_M_DMA_CB_ERROR, txerr); transferDone = false; spi_m_dma_register_callback(&SPI_0, SPI_M_DMA_CB_TX_DONE, txcb); spi_m_dma_enable(&SPI_0); io_write(io, &b, sizeof(b)); while (!transferDone); }
Please give me a hint what I might be doing wrong here. If necessary, I can prepare a minimal project with SPI over DMA configuration for you to review.