Issues with I2C for PIC18F252 and GLK12232-25-SM

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

Moderators: Henry, Mods

YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Issues with I2C for PIC18F252 and GLK12232-25-SM

Post by YYS »

Hi. My name is Yu-Chen. Some friends and I were trying to get the PIC18F252 to transmit data to the GLK12232-25-SM LCD via I2C. However, we are running into some trouble about the LCD not accepting input data.

The LCD is setup according to the changes indicated for PCB 1.4 of GLK12232-25-SM for the I2C, and connections have been checked to make sure that data is going through. A scope is also used to visually see actual bits being transmitted as well.

The code is written for the C18 compiler, using I2C commands predefined in its library. The code is main.c attached to this message. The data transmission command, putsI2C() (i2c_puts.c), is also included in the attachments. The codes are written with hardware peripheral functions, but there are also software peripheral functions. Those go under mainsoftware.c in the attachments. Mainsoftware.c is coded slightly different from main.c, but neither of them worked during testing.

For more information about C18 I2C commands, visit the following pdf and check on the pages listed below:

http://ww1.microchip.com/downloads/en/d ... 51297f.pdf

1. Hardware Peripheral Functions for I2C - Pg. 25-38

2. Software Peripheral Functions for I2C - Pg. 109-114

I was wondering if there were some problems in our coding that resulted in the LCD not accepting the commands we tried to input, and if anyone can post corrections that would be great.

Thanks.
Attachments
main.c
(740 Bytes) Downloaded 668 times
i2c_puts.c
(2.23 KiB) Downloaded 583 times
mainsoftware.c
(913 Bytes) Downloaded 880 times
Raquel
Matrix Orbital
Matrix Orbital
Posts: 834
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Hello Yu-Chen,

Thanks for your post.

I looked at your code and it looks good. I suggest though, that before drawing lines, maybe you want try to clear the screen first ( 254 / 88 )? Also, a side note, if you wanted to draw lines on the screen, there is a command for that: 254 / 108 / <+ parameters>.

What I would like to see is for a scope capture. If you please post a scope capture so we can slearly see what is happening on the SCL and SDA lines, something like the following post

Thanks,
Raquel Malinis
Design and Development
Matrix Orbital
YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Post by YYS »

Hi Raquel.

I will get you the scope captures tomorrow (because I'm not the one doing it, and the equipments are not at my place either), but I can explain some weird things about them right now. For one of the lines (I think it was SDA line) the voltage seems to drop below 5V while the other one stays at 5V with no problem.

As for the start up screen, I think we uploaded an empty bitmap using MOGD Sharp so that nothing appears on the start up screen right now. Also, we wanted to test the draw pixel feature, not the draw lines feature (despite in this testing we drew a diagonal line). That's the main reason why we didn't use draw lines command.

Thanks again.

Yu-Chen Shih
YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Post by YYS »

Hi again.

I found something on the manual today that could be the problem. Under the I2C section, it says to input the following commands 254/160/0 to the LCD to turn off the auto transmission of data in RS232. I checked the commands list and didn't see this anywhere, and we can't apply this command using MOGD# either (since MOGD# doesn't support hand typed commands, but it would be nice to include that feature to apply some commands not featured in the software to the LCD). I was wondering if I can apply this code using I2C (or would I have to do it through RS232)?

One other question. Due to some weird reason, our baud rate for RS232 is messed up, and setting it in MOGD# is no good either. Right now, the only way to keep the baud rate set properly is through the reset pins. I know that I have to save the settings in order to get rid of this problem, but I looked at the command list in the manual and don't see a save settings command (only save contrast and etc.). If someone can post the command that would be great.

Thanks again.

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

Post by Raquel »

Hello,

I am not sure what GLK12232-25-SM PCB you have. Do you have a Rev 2.0 or Rev 1.4?
Raquel Malinis
Design and Development
Matrix Orbital
YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Post by YYS »

Hi. We have Rev 1.4. I checked manual 1.4 and 2.0, but 254/160/0 command is not listed in either manual's command list. It is only mentioned by manual 2.0 in the I2C section on page 16.

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

Post by Raquel »

Command 254 / 160 is only for GLK12232-25-SM PCB 2.0. Mogd# is also for PCB Rev 2.0 only.

Do you have a scope capture yet?
Raquel Malinis
Design and Development
Matrix Orbital
YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Post by YYS »

Hi.

I see, we'll try MOGD and see if it fixes the baud rate issue. Although asides from that MOGD works fine in terms of bitamp uploading and text input testing.

The scope capture is listed below. I hope it will be of help in solving the problem.

Image

Thanks.

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

Post by Raquel »

Thanks for the capture.

I see that you are not getting ACK'ed although you are sending the right address. Can you please turn the power off, take off any keypad connected, and temporarily jump pins 6 and 7 of the keypad connector. Power the display back up and see if you get ACK'ed by the display.

Also, make sure that the lines idle high at the end of a transaction (I guess this should go without saying, when you STOP a transaction).
Raquel Malinis
Design and Development
Matrix Orbital
YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Post by YYS »

Hi Raquel. We got everything setup the way you said so, but we're still not getting any ACK from the LCD. I was wondering if we use writeI2C() (i2c_writ.c) and ackI2C() (i2c_ack.c) and send one char at a time would it bypass having to check for ACK from the LCD and just sends data to it instead? These two files are listed below and are default I2C commands in C18 for the PIC we're using

Thanks.

Yu-Chen Shih
Attachments
i2c_ack.c
(720 Bytes) Downloaded 555 times
i2c_writ.c
(1.01 KiB) Downloaded 430 times
Raquel
Matrix Orbital
Matrix Orbital
Posts: 834
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

You will need the display to ACKnowledge the data sent to it, this can not be bypassed at all.

Have you done the pin lifting and other I2C necessary changes for the PCB 1.4? They can be found here

Also, please make sure that the captured signals are taken from the display side, not at the PIC side, so that we know this is what the display is getting. I suggest that you get it on the I2C solder jumps.
Raquel Malinis
Design and Development
Matrix Orbital
YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Post by YYS »

Hi. I see, I guess there's no way to bypass it then.

As for the pin lifting, we already did that and followed the instructions there but still didn't get anything.

My friend will be getting more scope captures later today according to your suggestion about capturing signals on the display side.

Thanks.

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

Post by Raquel »

Hello,

I looked at the data sheet for the PIC18F252 and it seems that the pins for SCL and SDA are port pins C3 and C4. Just making sure that this is where you are connecting the display to. Also, the GLK12232-25-SM does not have pull-ups. You will need to put them on your master end. Thing is, I do see the waveforms (as you have captured), so I guess mine is just a double check here.
Raquel Malinis
Design and Development
Matrix Orbital
YYS
LCD!
Posts: 12
Joined: Mon Jun 11, 2007 11:27 am

Post by YYS »

Hi. I just got the scope captures and here they are now. For these scope captures, we used putcI2C() instead of putsI2C(). PutcI2C sends one char at a time, while putsI2C sends a whole string at a time. However, putsI2C doesn't have line idle high at the end but putcI2C does. Below is the new scope capture.

Image

Thanks.

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

Post by Raquel »

Do you still have pins 6 and 7 of the keypad connector jumped? We still do not see the display ACK'ing the address. With pins 6 and 7 jumped, the display puts the slave address to 0x50.

Did you by any chance change this slave address before?
Raquel Malinis
Design and Development
Matrix Orbital
Post Reply