SPI communication between two STR910

Hello,

I want to comunicate two STR910 micros via SPI. One of them will be the master, and other the slave. The code is very simple:

[b]MASTER:[/b]

/* CLK, MISO & MOSI configuration */
SCU->GPIOOUT[3] &= 0xC0FF;
SCU->GPIOOUT[3] |= 0x2200;
SCU->GPIOIN[3] |= 0x20;

/* SPI1 configuration */
SSP1->CR0 = 0x0007; /* CPHA=0, CPOL=0 */
SSP1->CR1 = 0x0002; /* Master mode & SSP Enable */
SSP1->PR = 0xFE;

/* Send data */
for(i=0;i<20;i++)
{ SSP1->DR = 0x41;
}

[b]SLAVE:[/b]

/* CLK, MISO & MOSI configuration */
SCU->GPIOOUT[3] &= 0xC0FF;
SCU->GPIOOUT[3] |= 0x0800;
SCU->GPIOIN[3] |= 0x40;
SCU->GPIOIN[3] |= 0x10;

/* SPI1 configuration */
SSP1->CR0 = 0x0007;
SSP1->CR1 = 0x0006; /* Slave Mode & SSP Enable */
SSP1->PR = 0xFE;

/* Receive data --> Status Register */
while((SSP1->SR & 0x04)==0);
for(i=0;i<20;i++)
{ buf[i] = SSP1->DR;
}

But I donÂ't receive anything. Which is the problem?

Thanks in advance.

Parents
  • I don't know your processor, but where did you specify the clock frequency for the master?

    And your slave should not wait until the flag toggles and then expect to be able to pick up 20 bytes. If the status register says data is available, you should pick up one byte and then check again if more is available. Reading multiple characters is only allowed if the status flag you look at is a "RX FIFO full".

    Another thing - are you sure the SPI slave can buffer 20 characters?

    And when you send - are you sure that your TX FIFO (does it have a FIFO?) can store 20 characters for transmission? If not, then you must pace the transmission instead of just jamming 20 characters into the data register.

    What have you done to debug? Have you looked at the MISO, MOSI and clock signals with an oscilloscope?

Reply
  • I don't know your processor, but where did you specify the clock frequency for the master?

    And your slave should not wait until the flag toggles and then expect to be able to pick up 20 bytes. If the status register says data is available, you should pick up one byte and then check again if more is available. Reading multiple characters is only allowed if the status flag you look at is a "RX FIFO full".

    Another thing - are you sure the SPI slave can buffer 20 characters?

    And when you send - are you sure that your TX FIFO (does it have a FIFO?) can store 20 characters for transmission? If not, then you must pace the transmission instead of just jamming 20 characters into the data register.

    What have you done to debug? Have you looked at the MISO, MOSI and clock signals with an oscilloscope?

Children
More questions in this forum