No announcement yet.

COM1 strange behaviour

  • Filter
  • Time
  • Show
Clear All
new posts

  • COM1 strange behaviour

    I am on working on a project that requires both COM ports on the uLCD-32PT.

    I am presently trying to communicate with the device via COM1. I am using the 4D terminal program on my PC to talk to a uUSB-MB5 which is wired to the GND, TX and RX pins on the touchscreen (J2 pins 17, 28 and 30).

    The code on the screen is slightly modified from the example code simply called 'serial'. I have just changed 'to(COM0)' to 'to(COM1)' and 'serin()' to 'serin1()'.

    Using an oscilloscope I have checked that the TTL output from the uUSB-MB5 is correct.

    However, whatever I type into the terminal (to send from the PC to the LCD) what is received at the processor (displayed on the LCD screen) is always 255 or 0xFF.

    If I try to send CHR data from the LCD to the PC it sends a single bit '1' which is displayed in the terminal as '00'.

    If I try to send HEX data from the LCD to the PC it sends a 29 bit message (always the same regardless of what the data is meant to be) which is displayed in the terminal as '00 00 00 00 00 00 00 00 00 00'.

    If I use COM0 to do the same thing (the only hardware difference being the use of different pins on J2) the LCD is then capable of receiving, displaying and transmitting sensible data.
    I repeated the test with another uLCD-32PT which had never been out of its packaging. The results were the same.

    What did I miss here? Maybe COM1 has different default settings to COM0? Any help appreciated.

  • #2

    Are you setting the correct baud rate on COM1? If you post your code it would be helpful .......
    Best Regards,


    • #3

      I'm not setting the baud rate - I think it's meant to default to 115200 like COM0, and COM0 is working fine.

      Here's my code. Sorry about the annoying smileys...

       #platform "uLCD-32PT_GFX2" 
      - serial interface test-
      -- PICASO Platform --
      func main()
      var ch, ch1;
      txt_Set(FONT_SIZE, FONT2);
      print ("Serial Input Test\n");
      print ("Download prog to flash\n");
      print ("Then use debug terminal\n");
      to(COM1); print("serial input test:\n");
      // now just stay in a loop
      ch := serin();
      if (ch >= 0)
      print( [HEX4] ch ); // if a key was received from PC, print its value
      to(COM0); print( [CHR] ch );
      ch1 := serin1();
      if (ch1 >= 0)
      print( [HEX4] ch1 ); // if a key was received from PC, print its value
      to(COM1); print( [CHR] ch1 );


      • #4

        have you tried it with a serial buffer - you may be receiving too quick and just displaying the last character which is the new line - which you wont see


        • #5

          I have found with the serial coms, 'ALWAYS' set the baud rate, and always com1_Reset(), then reset the baud rate after changing anything (buffered to polled etc).. it doesn't waste much code space and it has been the most reliable way for me.. But definately set the baud rate.

          MicroLec Industries P/L


          • #6
            Okay, I did both of those things and it is now working!
            Thanks very much, chaps.

             #platform "uLCD-32PT_GFX2"/*- serial interface test--- PICASO Platform --*///==================================================================================================func main()var ch, ch1, combuf;gfx_Cls();txt_Set(FONT_SIZE, FONT2);print ("Serial Input Test\n");print ("Download prog to flash\n");print ("Then use debug terminal\n");//COM0 apparently works without initializationcom1_Init(combuf, 20, 0 );com_SetBaud(COM1, 11520);to(COM1); print("serial input test:\n");// now just stay in a looprepeatch := serin();if (ch >= 0) //Ignore -1 (no character) and -2 (error)print( [CHR] ch );   // if a key was received from PC, print it to the screento(COM0); print( [CHR] ch ); //Echo data back to the COM portendif// Repeat for COM1ch1 := serin1();if (ch1 >= 0)print( [CHR] ch1 );   // if a key was received from PC, print it to the screento(COM1); print( [CHR] ch1 ); //Echo data back to the COM portendifforeverendfunc//==================================================================================================