glk12232-25 & pic18f8720 not work

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

Moderators: Henry, Mods

Post Reply
tzvika
LCD?
Posts: 4
Joined: Sun Jan 04, 2004 7:22 am

glk12232-25 & pic18f8720 not work

Post by tzvika »

I have a Matrix-Orbital glk12232-25 connect to pic18f8720 .
Icannot to "speak" with my lcd.
this is my code:

void wait_end_procc(void){
while(SSPIF==0);
SSPIF=0;
}

void start_bit(void){
SSPIF=0;
SEN=1;
wait_end_procc();
}

void stop_bit(void){
SSPIF=0;
PEN=1;
wait_end_procc();
}

void send_byte(uns8 dta){
SSPIF=0;
SSPBUF=dta;
wait_end_procc();
}

uns8 receive_byte(uns8 adr){
Carry=1;
adr=rl(adr);
start_bit();
send_byte(adr);
TEST2=1;
RCEN=1;
while(RCEN);
TEST2=0;
SSPIF=0;
ACKDT=0;
ACKEN=1;
wait_end_procc();
stop_bit();
return SSPBUF;
}

void write_byte_protocol(uns8 adr, uns8 command, uns8 dta){
Carry=0;
adr=rl(adr);
start_bit();
send_byte(adr);
send_byte(command);
send_byte(dta);
stop_bit();
}


uns8 read_byte_protocol(uns8 adr, uns8 command){
uns8 _adr;

_adr=adr;
Carry=0;
adr=rl(adr);
start_bit();
send_byte(adr);
send_byte(command);
stop_bit(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return receive_byte(_adr);
}




I'm use with "write_byte_protocol" function like this:

void clear_display(){
write_byte_protocol(80,254,88);
}

Finnaly the project not work .
thank for all.

Aniso
-=Beloved by all=-
-=Beloved by all=-
Posts: 286
Joined: Tue Aug 14, 2001 6:00 pm
Location: ...I could tell you my velocity...

Post by Aniso »

As always, tech support wants to eliminate variables.

-Does it work with other I2C devices?
-Have you tried ALL addresses (make a loop)?
-Have you tried another host attached to the display?
-If you are not going to use these routines for anything but Matrix displays, then you might as well eliminate the ACK / !ACK detection since ACK is pretty meaningless in this context, and it adds useless complexity. Matrix displays ALWAYS ACK even if there is no buffer space - the only time they fail to ACK is if you send data too fast to store, and that can be prevented in a systematic way, so watching ACK is pointless ultimately.
-If it were me, I would be more particular about the starts and stops. I am paranoid about my own stupidity, so I would be setting the other pins as well.

tzvika
LCD?
Posts: 4
Joined: Sun Jan 04, 2004 7:22 am

Post by tzvika »

:) Thank you for help!! :)
-This is the first product that i connect to this project & this is the meaning to check I2C.
-addresses- which addresses? I know 0X50 or 80.
-What the problem with stop/start?

Aniso
-=Beloved by all=-
-=Beloved by all=-
Posts: 286
Joined: Tue Aug 14, 2001 6:00 pm
Location: ...I could tell you my velocity...

Post by Aniso »

Addresses. The word in this context refers to the address of the I2C device. If you cannot talk to an I2C device, it is always a good idea to build a loop and try EVERY address to see if the device is actually listening to the address you THINK it is listening to. Start with address 2, and check 4, 6, 8, 10, etc, up to address 254. A cheesy version follows. A printf() type of thing could be used instead.

int one = 2;
int ten = 0;
int hun = 0;

for (count = 2; count < 255; Count+=2) {
Start();
SendByte(count);
SendByte (hun);
SendByte(ten);
SendByte(one);
Stop();

one+=2;
if (one > 9) {
ten++;
one = 0;
}
if (ten > 9) {
hun++;
ten = 0;
}
}

You get the idea. Send out the ASCII of each address TO each address till something appears on the display. If your hardware and base I2C functions are working this will ALWAYS put something on the screen. We have a little board here that just does this thing.

As for your Start and Stop, I was just refering to the fact that you set only the "appropriate line without checking the state of the other line. My Start() looks like this:

Start() {
SDA = 0;
delay_us(5);
SCL = 0;
}

Miles: do you have the URL for that good I2C reference?

tzvika
LCD?
Posts: 4
Joined: Sun Jan 04, 2004 7:22 am

lcd

Post by tzvika »

Thank you !
Adrresses- this is the only way to know the address?
The address not write in anywhere?

Post Reply