EmbeddedRelated.com
Forums

SPI1 Loop Back on AT91SAM7X-EK

Started by hudson_low August 12, 2008
Hi,

Any one have Problem with SPI1?

I am using my SAM7-EK to test the SPI code.

I started to test the spi code with internal loop back.
SPI_MR =(AT91C_SPI_MSTR | AT91C_SPI_MODFDI | AT91C_SPI_LLB)
and both SPI0 and SPI1 work.

Then I try with external Loop Back,(MISO and MOSI short tohether with
wire)
And I manage to get echo back on SPI0 but NOT on SPI1
with same set of code to configure the SPI0 and SPI1 as below:

Any one have any idea or similar problem with SPI1?
//----------------------------//
// Disable the interrupt
AT91C_BASE_AIC->AIC_IDCR = 0x1 << AT91C_ID_SPI1;
// Disable the PDC transfer
AT91C_BASE_SPI1->SPI_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;

// Enable the SPI in PMC
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_SPI1;

AT91C_BASE_SPI1->SPI_CR = AT91C_SPI_SWRST |AT91C_SPI_SPIEN;
AT91C_BASE_SPI1->SPI_MR = AT91C_SPI_MSTR | AT91C_SPI_MODFDI;

// Configure Chip select register
AT91C_BASE_SPI1->SPI_CSR[0] = SPI_NPCS0_CONFIG;

//----------------------------//
Thanks in advance

:)
I have found the solution:

http://www.at91.com/phpbb/viewtopic.php?t72&highlight=spi1