1

I'm writing an Arduino program to communicate with another module using RS485, so I need to control data flow with one pin. But when I set the pin to HIGH (line 88) it almost instantly falls (as you can see in the image, line 70). So my guess is that Arduino Serial.write() function is non-blocking, but I need it to be blocking enter image description hereso the flow control pin stays high during whole packet transmit. Please help. Thank you.

  • Please post the code as text rather than image. And indent it by selecting it and clicking the {} button. It makes things easier for those who want to help you. – Edgar Bonet Apr 14 '16 at 7:59
3

You are right: Serial.write() is non blocking: it puts the data in a buffer and waits for an interrupt routine to send it through the UART. If you want to wait for the transmission to complete, you can call Serial.flush().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.