GLK240128-25 Flow Control Help

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
BrotherBev
LCD?
Posts: 3
Joined: Fri May 18, 2007 10:55 am
Location: UC Davis

GLK240128-25 Flow Control Help

Post by BrotherBev »

Hello, I am having a little trouble using flow control with my MO display, and was hoping someone would be able to give me some tips. My display frequently gives me garbage or cuts off some characters when I send enough to cover about half the screen or more. I assume this is because the buffer is overflowing, so I tried to use this simple function to send all my commands to the display:

Code: Select all

void myCwrite(char *cmd, int len)  // takes the command to send and size
{
  int i;
  char status[1];

  for(i = 0; i < len; i++)
  {
    serCwrite(&cmd[i], 1);          // writes 1 byte to the port that has the display connected to it
    serCread(status, 1, 1000);    // reads 1 byte from the port
    if(status[0] == 0xFE)            // 0xFE indicates "almost full"
      while( status[0] != 0xFF )    // 0xFF indicates ready
        serCread(status, 1, 1000);
  }
}
This is how I initialize my flow control:

Code: Select all

void flowControl(int full, int empty)  // I typically use 25, 65 respectively
{
  char cmd[4];
  cmd[0] = 0xFE;
  cmd[1] = 0x3A;
  cmd[2] = full;
  cmd[3] = empty;
  serCwrite(cmd, 4);  // sends the command 0xFE 0x3A <full> <empty>
}
As I understand it from the manual, both flow control arguments represent the number of bytes remaining in the buffer, although I tried using 25, 25 as well.

Even using this function for my writes, I still get garbage towards the end of my transmissions. I am using a microcontroller board that only reads C and assembly, and am communicating through RS232 protocol. Any help you could give would be greatly appreciated. Thank you.

--David
Raquel
Matrix Orbital
Matrix Orbital
Posts: 834
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Hello David,

Thanks for your post.

In your myCwrite function, please make sure that serCread does not return 0xFF as a result of nothing to read on the port.

Do you actually see a 0xFE from the display? Do you successfuly get a 0xFF after getting a 0xFE?

Thanks,
Raquel Malinis
Design and Development
Matrix Orbital
BrotherBev
LCD?
Posts: 3
Joined: Fri May 18, 2007 10:55 am
Location: UC Davis

Post by BrotherBev »

Raquel,

Thank you for your help. After playing around with the display some more this week, I still couldn't discover what the problem was. I checked that 0xFF was not the default value with nothing to read, and the function does recieve 0xFE, waits, then eventually reads 0xFF and continues. However, for some reason, when placing the function in the larger program, I still found garbage, so it must just be something in my program interacting strangely with this function. I ended up just adding 5ms delay after each byte written to the display, and have not had any problems since. Thanks again.

--David
Post Reply