AT91SAM3U4E-EK Using SPI with PDC (DMA)

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

agrealish
Posts: 8
Joined: Thu Jul 28, 2011 4:14 pm

AT91SAM3U4E-EK Using SPI with PDC (DMA)

Fri Sep 16, 2011 5:33 pm

Hi,

I am having trouble setting up the SPI transfers using the PDC on a AT91SAM3U4E-EK Board. I can use the SPI with the PDC and that is working as expected. However, with thte PDC I see no output on theMOSI pins with a scope.
I am using the spi.c/spi.h library files from Atmel.

Sending data using this function works:
void SPI_Write_Last(AT91S_SPI *spi, unsigned int npcs, unsigned short data)
{
// Discard contents of RDR register
//volatile unsigned int discard = spi->SPI_RDR;

// Send data
while ((spi->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
spi->SPI_TDR = data | SPI_PCS(npcs);
spi->SPI_CR |= AT91C_SPI_LASTXFER ;
while ((spi->SPI_SR & AT91C_SPI_TDRE) == 0);
}

However, sending a buffer to this function returns 1 but I see no output on MOSI
unsigned char SPI_WriteBuffer(AT91S_SPI *spi, void *buffer, unsigned int length)
{
#if !defined(CHIP_SPI_DMA)
// Check if first bank is free
if (spi->SPI_TCR == 0) {

spi->SPI_TPR = (unsigned int) buffer;
spi->SPI_TCR = length;
spi->SPI_PTCR = AT91C_PDC_TXTEN;
return 1;
}
// Check if second bank is free
else if (spi->SPI_TNCR == 0) {

spi->SPI_TNPR = (unsigned int) buffer;
spi->SPI_TNCR = length;
return 1;
}
#endif
// No free banks
return 0;
}

If it helps I am setting up the SPI and CS as follows:
void SpiInit(void){

//Set bits to use peripheral
AT91C_BASE_PIOA->PIO_PDR |= (AT91C_PA13_SPI0_MISO | AT91C_PA14_SPI0_MOSI | AT91C_PA15_SPI0_SPCK | AT91C_PA16_SPI0_NPCS0);
//Clear bits to select peripheral A
AT91C_BASE_PIOA->PIO_ABSR &= ~(AT91C_PA13_SPI0_MISO | AT91C_PA14_SPI0_MOSI | AT91C_PA15_SPI0_SPCK | AT91C_PA16_SPI0_NPCS0);

SPI_Configure(AT91C_BASE_SPI0, AT91C_ID_SPI0, (AT91C_SPI_MSTR | AT91C_SPI_PS_FIXED | AT91C_SPI_MODFDIS) );

SPI_ConfigureNPCS(AT91C_BASE_SPI0, 0, (AT91C_SPI_CPOL | AT91C_SPI_NCPHA |
SPI_SCBR(mSpiSpeed, BOARD_MCK) | AT91C_SPI_CSAAT
| SPI_DLYBCT(1000, BOARD_MCK)) );
SPI_Enable(AT91C_BASE_SPI0);
TRACE_INFO("SPI Interface has been set up correctly. \n\r");

}

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest