Announcement

Collapse
No announcement yet.

Serai comunication problem when TOUCH_ENABLE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mario M
    replied
    Problem Solved....I was not aware that int the DT series PA12 and 13 are reserved. Used PA4 and PA5 instead

    Leave a comment:


  • Mario M
    started a topic Serai comunication problem when TOUCH_ENABLE

    Serai comunication problem when TOUCH_ENABLE

    Hi, I'm using a GEN4-ULCD-43DT. I have some forms where LedDigits and Buttons are present. I also created a function to communicate by a Serial 485 standard to another devise using COM1.
    The user interface in stand alone work as the serial communication work if used just to print data on the screen.
    When I call the serial communication function inside a Form nothing works, either the form freezes ore the serial communication doesn't work.
    I found out that by Disabling the touch function the serial communication works so I disable and enable it every time I want to communicate but that make the user interface inadequate and in any case after some time everything stop working.

    What am I missing? Is this a normal behavior?

    Thanks.

    This is the Serial communication function


    func S485()


    //buffer
    // print("S485 \n");
    touch_Set(TOUCH_DISABLE);
    var DIMBUF:= 49;
    var Mess[50];
    var SERBUF[49]; //100
    var ii :=0;
    var line:=0;
    //pins def
    pin_LO(PA11); // ricezione
    COM1_RX_pin(PA13); //GPIO14
    COM1_TX_pin(PA12); //GPIO13


    // com SETS
    com_SetBaud(COM1,960); // set baudrate for COM1
    com1_Init(SERBUF,DIMBUF, 's'); // initialize buffer for serial port COM1
    //print("Running...\n");
    pin_LO(PA11); // ricezione
    pause (10);
    // repeat


    //print(com1_Full());
    //line++;
    // messaggio ricevuto
    if (com1_Full())//( com1_Count() > DIMBUF-1)
    // print("buffer full \n");
    // controllo che la seconda lettera sia t
    if (SERBUF[0]=='t')
    // copio dal SERBUF
    for(ii:=1;ii<DIMBUF;ii++)
    Mess[ii] :=serin1();//print(Mess[ii]);
    next
    com1_Init(SERBUF,DIMBUF, 's'); //pulitura buffer




    // temperature
    var TEMP_START := 10;
    var T0,T1,T2,T3;
    T0:= 255*Mess[TEMP_START] + Mess[TEMP_START+1];//print(T0); print(" ");
    T1:= 255*Mess[TEMP_START+2] + Mess[TEMP_START+3];//print(T1); print(" ");
    T2:= 255*Mess[TEMP_START+4] + Mess[TEMP_START+5];//print(T2); print(" ");
    T3:= 255*Mess[TEMP_START+6] + Mess[TEMP_START+7];//print(T3); print(" \n");
    else
    com1_Init(SERBUF,DIMBUF, 's'); //pulitura buffer
    endif
    touch_Set(TOUCH_ENABLE);
    // return ;
    endif
    touch_Set(TOUCH_ENABLE);
    // print("sto uscendo da S485 \n");
    return;
    // forever
    endfunc
Working...
X