3

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
asked Nov 18, 2015 at 14:31

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.