Sending with this function here works fine:
uint16_t usart0spiTransfer16(uint16_t spiMessage16) {
uint16_t sdo = 0;
byte firstByte = spiMessage16;
byte secondByte = (spiMessage16 >> 8);
while (((USART0->US_CSR >> 1) & 1) == 0);
digitalWrite(SS, LOW);
USART0->US_THR = secondByte; //write to USARTO Transmit Hold Register
//this byte is returned twice
secondByte = USART0->US_RHR; //read from USART0 Receive Hold Register
while (((USART0->US_CSR >> 1) & 1) == 0); //TXRDY: Transmitter Ready
USART0->US_THR = firstByte;
//trying to read a second time gives me the same value as before
firstByte = USART0->US_RHR;
while (((USART0->US_CSR >> 9) & 1) == 0);
digitalWrite(SS, HIGH);
sdo = (firstByte << 8 ) | (secondByte & 0xFF);
return sdo;
}
and when i wait for RXRDY after secondByte = USART0->US_RHR;
with while (((USART0->US_CSR >> 0) & 1) == 0);
i will stay there forever since it does not change
how do i read the registers value for the second time?
VE7JRO
2,51519 gold badges27 silver badges29 bronze badges