Any Ardino system software gurus out there?
Am I correct that the current Audino hardware serial library code does not use buffered output for the serial transmit? The code below, shows a busy-loop waiting on the prior byte to finish before sending the next. Unlike the hardware serial receive functions, there seems to be no ring buffer on the output, and use of transmit interrupts.
This busy loop would hose up timing-dependent code.
void HardwareSerial::write(uint8_t c)
{
while (!((*_ucsra) & (1 << _udre)))
;
*_udr = c;
}
stevech:
Any Ardino system software gurus out there?
Am I correct that the current Audino hardware serial library code does not use buffered output for the serial transmit? The code below, shows a busy-loop waiting on the prior byte to finish before sending the next. Unlike the hardware serial receive functions, there seems to be no ring buffer on the output, and use of transmit interrupts.
This busy loop would hose up timing-dependent code.
void HardwareSerial::write(uint8_t c)
{
while (!((*_ucsra) & (1 << _udre)))
;
*_udr = c;
}
Perhaps a better question (I'm a c++ newbie) is: Are there derived functions for HardwareSerial::write() that implement buffered output?
agree. But even a 128 byte output buffer would be a wise use of RAM. The application could check if that buffer is is too full before sending more output, and based on that, could elect to defer and do other processing. With the current unbuffered output, the application is likely to spin in a busy-loop on the UART output. At the default 9600 baud, this is about a millisecond of wasted CPU time and that’s a lot of instruction cycles!