Go Down

Topic: [SPI] DUE as SPI Slave (Read 201 times) previous topic - next topic


Hey guys,

While I did managed to get the DUE configured as a Slave, the code is behaving chaotically - in the sense that it works perfectly for 15 seconds, after which the data on the MISO line gets distorted

What i mean by distorted is that I do write 0x4AD3 in the TD register, but on the oscilloscope I see something like 0xAD34. Any thoughts?

Code: [Select]

void setup()
  //Change the SPI Write Protection Mode Register
  //with the key and the Write Protection disable

  REG_SPI0_MR = (0 << SPI_MR_MSTR);
  //SPI enable
  //Changes the SPI clock and the number of bits transferred

  //wait for a valid reception: SR & SR_RDRF (Receive Data Register Full) will be set to 1
  while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0)
  int16_t d = SPI0->SPI_RDR & 0x0000FFFF;

  //send a response: TDR(Transmit Data Register)
  while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0)
  SPI0->SPI_TDR = 0x1234 | SPI_PCS(10);// on the oscilloscope, on the MOSI line  I get 0x4123;


Go Up