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)))


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 Gray aka the GRAYnomad www.robgray.com


Nick Gammon


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)


Ok, thanks that makes sense

Go Up