Hallo,
I use an SAM3X8 (Arduino-DUE) and use USART0 as SPI-Interface in slave-mode. In a test circuit I use the standard SPI as master that sends data to the USART-SPI (as slave). It works in principle with one exception: The RXRDY-Bit in the USART Channel Status Register (US_CSR) is always 0, even if the sent data have been arrived a ms ago in the USART Receive Holding Register (US_RHR). I tried it with interrupts, but no interrupt was triggered.
(In my test circuit I now, when data shoul be arrived in the US-RHR of the slave, but typically, a slave can only wait.)
Does anybody have an idea?
Below the kernel of my code.
GreatingsGuaAck
void USART0config(uint16_t divider) { USART0->US_WPMR = 0x55534100; // Unlock the USART Mode register USART0->US_MR |= 0x409CF; // Set Mode to CLK0=1, 8_BIT, SPI_SLAVE (CPOL = 1 0x508CE, CPHA = 1 0x409CE, both set to 1 0x509CE) PIOA->PIO_WPMR = 0x50494F00; // Unlock PIOA Write Protect Mode Register PIOB->PIO_WPMR = 0x50494F00; // Unlock PIOB Write Protect Mode Register PIOB->PIO_ABSR |= (0u << 26); // CS: Assign PB26 I/O to the Peripheral A function PIOB->PIO_PDR |= (1u << 26); // CS: Disable PIO control, enable peripheral control PIOA->PIO_ABSR |= (1u << 17); // SCK: Assign PA17 I/O to the Peripheral B function PIOA->PIO_PDR |= (1u << 17); // SCK: Disable PIO control, enable peripheral control PIOA->PIO_ABSR |= (0u << 10); // MOSI: Assign PA10 I/O to the Peripheral A function PIOA->PIO_PDR |= (1u << 10); // MOSI: Disable PIO control, enable peripheral control PIOA->PIO_ABSR |= (0u << 11); // MISO: Assign PA11 I/O to the Peripheral A function PIOA->PIO_PDR |= (1u << 11); // MISO: Disable PIO control, enable peripheral control } void loop() { volatile word US_CSRWert; byte swert; byte ewert; swert = 0; while (true) { // Zeichen Senden pinport -> PIO_CODR = pinmask ; // clear SS-pin SPI.transfer(swert); pinport -> PIO_SODR = pinmask ; // set SS-pin delay(1); // Zeichen sollte empfangen sein US_CSRWert = USART0->US_CSR; // Reading may change content Serial.print(swert); Serial.print(" --> "); delay(100); if (true) { // statt if ((USART0->US_CSR & 0x1)!=0) o. ä. Serial.print("US_CSR \t"); Serial.print(US_CSRWert, HEX); Serial.print("; "); US_CSRWert = USART0->US_CSR; // Reading may change content Serial.print(US_CSRWert, HEX); Serial.print("; "); ewert = USART0->US_RHR & 0xFF; Serial.print(ewert); Serial.print("; US_CSR \t"); US_CSRWert = USART0->US_CSR; // Reading may change content Serial.println(US_CSRWert, HEX); } else { Serial.println("-?-"); } delay(1000); swert = (swert + 1); } }