EmbeddedRelated.com
Forums

Problems with SPI

Started by Sebastian Kronenwerth October 27, 2010
Hi everybody,

I was sitting more than four houres on the same problem and I don't find
an approach to fix it. So I hope anyone of you can help me!

I have an ARM9 processor and try to use the SPI-Bus correctly. The PINs
SCK and NTPC work fine but the whole time I have a high signal at my
MOSI pin.

My code is similar to this (and I use the at91lib from Atmel):

#include
#include
#include
#include

int main(void) {

// configure SPI1-SPCK
AT91C_BASE_PIOB->PIO_PDR |= (1<<29);
AT91C_BASE_PIOB->PIO_ASR |= (1<<29);

// configure SPI1-MISO
AT91C_BASE_PIOB->PIO_PDR |= (1<<30);
AT91C_BASE_PIOB->PIO_ASR |= (1<<30);

// configure SPI1-MOSI
AT91C_BASE_PIOB->PIO_PDR |= (1<<31);
AT91C_BASE_PIOB->PIO_ASR |= (1<<31);

// configure SPI1-NPCS1
AT91C_BASE_PIOA->PIO_PDR |= (1<<24);
AT91C_BASE_PIOA->PIO_BSR |= (1<<24);

SPI_Configure(AT91C_BASE_SPI1,AT91C_ID_SPI1,0x70000013);
SPI_ConfigureNPCS(AT91C_BASE_SPI1,1,0x0440FF0A);
SPI_Enable(AT91C_BASE_SPI1);

while(1) {
SPI_Write(AT91C_BASE_SPI1,1,0xAA);
}

return 0;
}

Has anyone an idea what is wrong?

Many thanks in advance,
Sebastian

Take a look at my code. I wasn't able to gert anything useful out of my peripheral (the CS wouldn't toggle), but I was able to send through MOSI.

http://www.at91.com/forum/viewtopic.php/f,9/t,19459/

R.

--- On Wed, 10/27/10, Sebastian Kronenwerth wrote:

From: Sebastian Kronenwerth
Subject: [AT91SAM] Problems with SPI
To: A...
Date: Wednesday, October 27, 2010, 2:48 PM

Hi everybody,

I was sitting more than four houres on the same problem and I don't find
an approach to fix it. So I hope anyone of you can help me!

I have an ARM9 processor and try to use the SPI-Bus correctly. The PINs
SCK and NTPC work fine but the whole time I have a high signal at my
MOSI pin.

My code is similar to this (and I use the at91lib from Atmel):

#include
#include
#include
#include

int main(void) {

// configure SPI1-SPCK
AT91C_BASE_PIOB->PIO_PDR |= (1<<29);
AT91C_BASE_PIOB->PIO_ASR |= (1<<29);

// configure SPI1-MISO
AT91C_BASE_PIOB->PIO_PDR |= (1<<30);
AT91C_BASE_PIOB->PIO_ASR |= (1<<30);

// configure SPI1-MOSI
AT91C_BASE_PIOB->PIO_PDR |= (1<<31);
AT91C_BASE_PIOB->PIO_ASR |= (1<<31);

// configure SPI1-NPCS1
AT91C_BASE_PIOA->PIO_PDR |= (1<<24);
AT91C_BASE_PIOA->PIO_BSR |= (1<<24);

SPI_Configure(AT91C_BASE_SPI1,AT91C_ID_SPI1,0x70000013);
SPI_ConfigureNPCS(AT91C_BASE_SPI1,1,0x0440FF0A);
SPI_Enable(AT91C_BASE_SPI1);

while(1) {
SPI_Write(AT91C_BASE_SPI1,1,0xAA);
}

return 0;
}

Has anyone an idea what is wrong?

Many thanks in advance,
Sebastian



Yahoo! Groups Links