Registers on pro micro

Hello. Attempting to get at data for the Serial1 registers on a pro micro. I’m looking at the 32U4 documentation and am in a bit over my head. I am wanting the following bit of code, but for the pro micro serial1:

 while (!(UCSR0A & (1 << UDRE0)))  // Wait for empty transmit buffer
     UCSR0A |= 1 << TXC0;  // mark transmission not complete
 while (!(UCSR0A & (1 << TXC0)));   // Wait for the transmission to complete

And going forward, how would I interpret that bit of code and modify it myself, given the documentation?

Thanks for any help.

Turns out just changing the 0's to 1's did the trick. Seems too easy, but it's working!

why can’t you just use the Serial1 instance to get the bytes ?

The "zeroes to ones" comment is not very clear (even though I know what you mean :) ). For the benefit of anyone who may read this post in the future, you should post your modified code.

aarg:
The “zeroes to ones” comment is not very clear (even though I know what you mean :slight_smile: ). For the benefit of anyone who may read this post in the future, you should post your modified code.

Sure!

while (!(UCSR1A & (1 << UDRE1)))  // Wait for empty transmit buffer
     UCSR1A |= 1 << TXC1;  // mark transmission not complete
 while (!(UCSR1A & (1 << TXC1)));   // Wait for the transmission to complete

His code was for Serial, I needed Serial1.

The whole point of this is to halt the program until I’ve finished dumping a packet of data. I turn on the enable pin, send the message, and then need it to immediately turn off the enable pin afterwards.

J-M-L:
why can’t you just use the Serial1 instance to get the bytes ?

After some quick reading, would Serial1.flush() accomplish the same thing?

yes, flush waits for the outgoing transmission to complete.

J-M-L: yes, flush waits for the outgoing transmission to complete.

Okay. The code I was following along with was from 2011, so flush didn't work that way at the time. That bit of code was literally under the header "Flushing the output", so I guess I should have known better.

yeah in the old days prior to Arduino 1.0, flush() would remove any buffered incoming serial data.