Go Down

Topic: rs485 protocol sound good? (Read 1 time) previous topic - next topic

Nick Gammon

Don't make life too complicated:

Code: [Select]

  // wait for transmit buffer to empty
  while (!(UCSR0A & _BV (TXC0)))
    {}
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Graynomad

#16
Jun 14, 2012, 12:45 am Last Edit: Jun 14, 2012, 12:46 am by Graynomad Reason: 1
Ok, it works just fine, I had the Leonardo board selected in the IDE  :0

This compiles

Code: [Select]
void setup() {
    int txEmpty = UCSR0A  & (1 << TXC0);
}

void loop() {}


So use a loop like Nick's example above.
______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

winner10920


Nick Gammon

This:

Code: [Select]
#define _BV(bit) (1 << (bit))

It returns the n'th bit.

So, _BV (1) is 2, _BV (2) is 4, and so on.

It just saves you writing:

Code: [Select]
(1 << TXC0)

Instead you can write:

Code: [Select]
_BV (TXC0)
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

winner10920

Ok, thanks that makes sense

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy