Go Down

Topic: RS232 handshaking (Read 320 times) previous topic - next topic

aceton

This is part of my code

Quote


#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);
const int sw1 = 3;
int zn;
int x=0;

void ini_comm(){
 Serial.end();    
 Serial.begin(2400);  
 UCSR0C = ( UCSR0C & ~_BV(UPM00) | _BV(UPM01) );
} //UPM01=1 --> Parity on  UPM00=0-->Even  

void setup() {
 lcd.begin(16, 2);
 pinMode(sw1, INPUT);
 digitalWrite(sw1,HIGH);
 lcd.print("1 start  ");
 lcd.setCursor(0, 1);
}

void loop(){
 if(digitalRead(sw1)==LOW)
 {
   delay(1000);
   lcd.clear();
   ini_comm();     // ini comm
   Serial.write(0xF4);
   Serial.write(0x03);
   Serial.write(0x51);
   Serial.write(0x0A);
   Serial.write(0xAC);
 }
 if (Serial.available() > 0) {
   zn = Serial.read();
   lcd.print(zn,HEX);
   lcd.print(' ');
 }
}




I don't have reply on LCD ( terminal show repply ).
It looks like RX start with little latency. Why ?



Osgeld

maybe cause you delay for a second, which stops your whole program?
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

aceton

Delay is only for switch. ( no repeating ini comm ).
It does not matter for reciving !!!!!!!!
  ini_comm();     // ini comm
    Serial.write(0xF4);
    Serial.write(0x03);
    Serial.write(0x51);
    Serial.write(0x0A);
    Serial.write(0xAC);

When I send F4 03 51 0A AC I see response on terminal but don't see on LCD !!!

Go Up