|
|
View previous topic :: View next topic |
Author |
Message |
Gu Guest
|
Glcd doesnt work! |
Posted: Sat Nov 17, 2007 8:23 am |
|
|
Hello,
I´m using a PIC16F877A to controll the tech 12864, a 128x64 glcd.
I can set the display contrast very well and the pic is working fine. I have a flat cable connecting the GLCD to board. Bu the displays seems not to work!!
I could see in an oscilloscope that the bits are going right withou the connection to the GLCD. When I plug the cable in the GLCD, my DATA bus get stuck to "zero".
By the way, i dont use the PORT D for the Data bus, I have de data bus splitted in ports B and C.
I made a simulation of my program at Proteus and it´s working fine.
Evem a simple code doesnt make the display to wotk!!
Can anyone help me please??? |
|
|
chrisaljar
Joined: 18 Nov 2007 Posts: 1
|
|
Posted: Sun Nov 18, 2007 3:32 pm |
|
|
hello gu
post your code dude,
chris |
|
|
Gu Guest
|
|
Posted: Mon Nov 19, 2007 12:15 pm |
|
|
Hi, Chris
My code is way too long, so I´m posting here only the part I've changed to work with my data bus. I have de data0-4 in port B (B3-B7) and data5-7 in port C (C0-C2).
Mostly, I used the GLCD.h and changed as I wanted...
Code: |
#ifndef GLCD_CS1
#define GLCD_CS1 PIN_C3 // Chip Selection 1
#endif
#ifndef GLCD_CS2
#define GLCD_CS2 PIN_C5 // Chip Selection 2
#endif
#ifndef GLCD_DI
#define GLCD_DI PIN_B0 // Data or Instruction input
#endif
#ifndef GLCD_RW
#define GLCD_RW PIN_B1 // Read/Write
#endif
#ifndef GLCD_E
#define GLCD_E PIN_B2 // Enable
#endif
#ifndef GLCD_RST
#define GLCD_RST PIN_C4 // Reset
#endif
#define GLCD_LEFT 0
#define GLCD_RIGHT 1
// Purpose: Write a byte of data to the specified chip
// Inputs: 1) chipSelect - which chip to write the data to
// 2) data - the byte of data to write
void glcd_writeByte(int1 side, int data)
{
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
output_low(GLCD_RW); // Set for writing
set_tris_b(0x00);
set_tris_c(0x00);
output_bit(pin_B3,bit_test(data,0)); // Put the data on the port
output_bit(pin_B4,bit_test(data,1));
output_bit(pin_B5,bit_test(data,2));
output_bit(pin_B6,bit_test(data,3));
output_bit(pin_B7,bit_test(data,4));
output_bit(pin_C0,bit_test(data,5));
output_bit(pin_C1,bit_test(data,6));
output_bit(pin_C2,bit_test(data,7));
delay_cycles(1);
output_high(GLCD_E); // Pulse the enable pin
delay_cycles(5);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
// Purpose: Reads a byte of data from the specified chip
// Ouputs: A byte of data read from the chip
int glcd_readByte(int1 side)
{
int data, datab, datac, i; // Stores the data read from the LCD
set_tris_b(0xF8); // Set port b and c to input
set_tris_c(0x07);
output_high(GLCD_RW); // Set for reading
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
delay_cycles(1);
output_high(GLCD_E); // Pulse the enable pin
delay_cycles(4);
datab = input_b(); // Get the data from the display's output register
datac = input_c();
set_tris_b(0xF8);
set_tris_c(0x07);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
for (i=3;i<8;i++) //data é composto de B3 a C2
{
if(bit_test(datab,i))
bit_set(data,i-3);
else
bit_clear(data,i-3);
}
for (i=0;i<3;i++)
{
if (bit_test(datac,i))
bit_set(data,i+5);
else
bit_clear(data,i+5);
}
return data; // Return the read data
}
|
Thanks a lot![/code] |
|
|
Gu Guest
|
|
Posted: Mon Nov 19, 2007 12:24 pm |
|
|
Anyway, I know the PIC is working, so I think the GLCD is gone...
I will try another one also. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|