Go Down

Topic: How can I Send BREAK Signal to USART ?  (Read 22 times) previous topic - next topic

heaven2

Board : Arduino DUE

Serial2 connect some device.
I want to send BREAK signal to Serial2.

Following code make hardware break signal to Serial2.
Working good~!

But,

After Send Break Just One Time,
Serial2 Tx Pin can't send any data.
So, After Send Break, can't communicate Serial2 device;

What's wrong this code ?


Code: [Select]

void SendBreak(int ms);
char c;

//////////////////////////////////////////////////////////////////////////////////////////
void setup() {
    Serial.begin(9600);
    Serial2.begin(9600);
   
    Serial.println("Ready...");
}

//////////////////////////////////////////////////////////////////////////////////////////
void loop() {
   
    SendBreak(500);                       // Send BREAK Signal to Serial2 .. Wake up Serial2 Device
   
    for ( int i = 0 ; i < 50 ; i++ ) {    // 5 second waiting..
        delay(100);                       // Serial2 device reset, and print banner
        while (Serial2.available()) {     // Company, Device Name, Version, etc..
            c = Serial2.read();
            Serial.print(c);
        }         
    }
   
    Serial2.write("C?\r",3);              // Request Device status

    for ( int i = 0 ; i < 50 ; i++ ) {    // not responding in 5 second.
        delay(100);   
        while (Serial2.available()) {
            c = Serial2.read();
            Serial.print(c);
        }         
    }     

}

//////////////////////////////////////////////////////////////////////////////////////////
void SendBreak(int ms)
{
    Serial2.end();             // Release Serial Mode
   
    pinMode(16, OUTPUT);       // Setup Output mode
    digitalWrite(16, HIGH);    // Send BREAK Signal
    delay(ms);                 // 500 ms
    digitalWrite(16, LOW);     // Set Idle Status
   
    Serial2.begin(9600);       // Serial Mode Begin
}


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