RS232 communications with a PIC chip

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

Moderators: Henry, Mods

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

Post by Raquel »

Hi arney,

I hope that you won't have to keep working on it too long and that we will hopefully get somewhere. Do you have an oscilloscope? I suggest that we go down on the pins and see what is actually happening. Also, at this point, how is the LCD acting, do you at least see 'H and 'I' (lots of them) and only the '2' and '3' are the ones you do not see, or you see some of the '2's and '3's but not as often as you expect?

Also , please try in the ISR:

Code: Select all

void HighISR (void) 
{
  unsigned char temp;
  if (INTCONbits.RBIF == 1)
  {
    if (SW2 == 0)
    {
      writeLCD('2');
      //debug
      if (LATAbits.RA1) PORTAbits.RA1 = 0;
      else PORTAbits.RA1 = 1;	
      // debug		
    }
    // skip SW3 for now  	
    temp = PORTB;
    INTCONbits.RBIF = 0;	
  } 
}
With the above code, you should see RA1 toggle every single time the button is pressed. If you do, then there should also be activity on the TX pin thus sending the character to the LCD.
Raquel Malinis
Design and Development
Matrix Orbital

arney
LCD!
Posts: 12
Joined: Fri Nov 11, 2005 8:54 pm

Post by arney »

Ok, I figured it out! My RS232 level converter is faulty. It's supposed to power down between transmissions, but for some reason it wouldn't come back up after it powers down the first time while connected to the LCD. I can't explain why it works fine with my PC and not whit the LCD, though. If I configure it to always stay on, it works fine with the LCD, though?!?!?!? Thank you for all of your help!

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

Post by Raquel »

Hi arney,

I'm glad that you have figured out what was wrong. Just so you know, you can also communicate with the LCD2041 via TTL and with TTL you wouldn't need an RS232 converter. Please see the manual how to configure the LCD2041 to TTL levels and so you may connect the PIC directly to the LCD.

If you have any more concerns please do not hesitate to post them.
Raquel Malinis
Design and Development
Matrix Orbital

arney
LCD!
Posts: 12
Joined: Fri Nov 11, 2005 8:54 pm

Post by arney »

Yeah, I know about bypassing the voltage converter chip, but the dev board I have already has the RS232 chip in place. Also this allows me to use my PC's com port to troubleshoot, etc... And I've got the problem fixed now, so if it ain't broke...

arney
LCD!
Posts: 12
Joined: Fri Nov 11, 2005 8:54 pm

Post by arney »

Another question, I meant to ask before, is, is there a way to designate HEX values in a string? What I mean is, something similar to \r or \n? like \0xFE?

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

Post by Raquel »

Unfortunately, no. You will just have to declare an unsigned char array; so instead of:

char string1[] = "Hello";

you will need to have
unsigned char string1 [] = {'H', 'e', 'l', 'l', 'o', 0xFE};

to squeeze in 0xFE
Raquel Malinis
Design and Development
Matrix Orbital

arney
LCD!
Posts: 12
Joined: Fri Nov 11, 2005 8:54 pm

Post by arney »

Yeah, thanks, I didn't think it could be done that way, but I thought I'd ask.

Jeroen Vonk
LCD Guru
Posts: 55
Joined: Tue Apr 12, 2005 2:31 am

Post by Jeroen Vonk »

arney wrote:Another question, I meant to ask before, is, is there a way to designate HEX values in a string? What I mean is, something similar to \r or \n? like \0xFE?
Why not replace \0xFE in your procedure/method to write to the display? Something like this (pseudo code):

Code: Select all

void writeStrLCD (string txdata)
{
  txdata = Replace(txdata,'\0xFE',char(0xFE));
  for (int i=0 to txdata.length-1) do
    writeLCD(txdata[i]);
} 

Post Reply