Problem of using SPI with PDC

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

wavelets
Posts: 3
Joined: Thu Sep 24, 2009 4:45 pm

Problem of using SPI with PDC

Thu Sep 24, 2009 4:50 pm

I wanna use spi with pdc and have tried the following test code in the evaluation board SAM3U-EK. The problem is that one cann't write the registers for pdc (e.g. spi->SPI_TPR spi->SPI_TCR spi->SPI_PTCR) in the function "SPI_WriteBuffer". Who can find the problem? Thank you very much!!

int main(void)
{
int i;
unsigned short spi_buff[8];
for( i=0; i<8; i++)
{
spi_buff = i;
}

PMC_EnablePeripheral(AT91C_ID_PIOA); //turn on PIOA peripheral
PIO_Configure(spi_pins, PIO_LISTSIZE(spi_pins)); //conf MISO,MOSI,SPCK,NPCS
PMC_EnablePeripheral(AT91C_ID_SPI0); //turn on SPI0


//conf SPI: master mode, mode fault disabled, PS_FIXED and set PCS, DLYBCS
SPI_Configure(AT91C_BASE_SPI0,AT91C_ID_SPI0,
AT91C_SPI_MSTR | // set master mode
AT91C_SPI_MODFDIS| // mode fault disabled
AT91C_SPI_PS_FIXED| // fixed peripheral select
(0x00 << 16)| // PCSDEC=0, the chip selects are directly connected to a peripheral device
// PCS = xxx0, NPCS0 enabled
);


//conf NPCS0:
SPI_ConfigureNPCS(AT91C_BASE_SPI0,0,
CPOL|
NCPHA|
AT91C_SPI_CSNAAT| // CSAAT=0: the peripheral chip select line rises as soon as the last transfer is achieved.
// CSNAAT=1: The peripheral chip select rises systematically between each transfer performed on the same slave
// for a minimal duration of: DLYBCS/MCK
AT91C_SPI_BITS_16| // Bits per transfer
( 0x2 << 8 ) // SCBR: serial clock baud rate (SPCK Baudrat = MCK / SCBR)
);
while(1)
{
SPI_Enable(AT91C_BASE_SPI0); //enable SPI

AT91C_BASE_SPI0->SPI_PTCR = AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS;

SPI_WriteBuffer( AT91C_BASE_SPI0, spi_buff, 8 );

while( AT91C_BASE_SPI0->SPI_RCR != 0 );

SPI_Disable(AT91C_BASE_SPI0); //disable SPI
}
}
wavelets
Posts: 3
Joined: Thu Sep 24, 2009 4:45 pm

Re: Problem of using SPI with PDC

Fri Sep 25, 2009 3:21 pm

perhaps there is no pdc for spi? one can only use the dmac for spi???
GPlanisi
Location: Spain
Posts: 24
Joined: Thu Dec 29, 2005 10:05 am

Re: Problem of using SPI with PDC

Fri Sep 25, 2009 3:49 pm

I have read only a little bit of the datasheet, and AFAIK, SPI has no PDC, and only DMA is allowed.

But, if you use an USART in SPI mode, then you will have PDC for that channel.

But don't forget that I'm not an expert with that IC, and that right now I can only be relatively sure about pinouts, package and schematics.
bdenis
Contact:
Posts: 48
Joined: Tue Feb 08, 2005 1:56 pm

Re: Problem of using SPI with PDC

Sat Sep 26, 2009 9:20 am

GPlanisi wrote:I have read only a little bit of the datasheet, and AFAIK, SPI has no PDC, and only DMA is allowed.

But, if you use an USART in SPI mode, then you will have PDC for that channel.
Yes I confirm.
thefox
Posts: 1
Joined: Wed Nov 11, 2009 11:01 am

Re: Problem of using SPI with PDC

Thu Nov 12, 2009 11:08 am

Does anybody have an example code how to use the "DMAD" code of the at91lib together with the SPI core?

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: Google [Bot] and 2 guests