Pages: 1 [2]   Go Down
Author Topic: rs485 protocol sound good?  (Read 1282 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't make life too complicated:

Code:
  // wait for transmit buffer to empty
  while (!(UCSR0A & _BV (TXC0)))
    {}
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, it works just fine, I had the Leonardo board selected in the IDE  smiley-mad

This compiles

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

void loop() {}

So use a loop like Nick's example above.
______
Rob
« Last Edit: June 13, 2012, 05:46:56 pm by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What does the _BV do?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This:

Code:
#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:
(1 << TXC0)

Instead you can write:

Code:
_BV (TXC0)
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, thanks that makes sense
Logged

Pages: 1 [2]   Go Up
Jump to: