Atmel Start on SAMV70 - trouble with SPI DMA configuration

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

This topic has a solution.
Last Edited: Mon. Aug 2, 2021 - 06:34 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After a long while, I have managed to find out what was wrong. Default XDMAC configuration doesn't work with SPI. I had to switch AHB_IF0 to AHB_IF1. After changing this, communication worked, but...

 

...there was a bug in read/write functions for SPI DMA driver. Attached a patch fixing it.

Attachment(s):