serial LCD needs delay?
kdoggfunkstah
Posts: 3
I purchased the serial lcd from parallax and I've been testing it out interfacing it with a pic microcontroller.
I wrote code in order to send characters via the uart in the pic. When I first tried to run this, it shot out garbage, except for the first few characters. I played around and tried to put in a delay between each character and it fixed the problem. However, the specs do not mention this and I would like to not have this delay due to the large amount of time it takes to update a whole screen.
Can anyone help me out with this one? Thanks!
I wrote code in order to send characters via the uart in the pic. When I first tried to run this, it shot out garbage, except for the first few characters. I played around and tried to put in a delay between each character and it fixed the problem. However, the specs do not mention this and I would like to not have this delay due to the large amount of time it takes to update a whole screen.
Can anyone help me out with this one? Thanks!
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
In my host controller code I have it so the uart does not send another data until the data is fully sent. Should there be a feedback from the lcd module that should tell my controller that it is safe to send another character?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
void init_LCD()
{
PORTCbits.RC6=1;
Delay10KTCYx(51); // 100ms delay
putcUSART(0x0C); // Clear LCD Screen
while(BusyUSART());
Delay100TCYx(40);
}
and here is the current lcd output function:
void out_lcd(void)
{
// x position
// convert to ascii numbers
// send one by one
for(i=0;i<5;i++)
{
putcUSART(x_ascii); // put in array
while(BusyUSART());
Delay100TCYx(40);
}
// send to position 6 0x86
// y position
for(i=0;i<5;i++)
{
putcUSART(y_ascii); // put in array
while(BusyUSART());
Delay100TCYx(40);
}
// send to position 12: 0x8C
// z position
for(i=0;i<5;i++)
{
putcUSART(z_ascii); // put in array
while(BusyUSART());
Delay100TCYx(40);
}
// pitch
for(i=0;i<5;i++)
{
putcUSART(pitch_ascii); // put in array
while(BusyUSART());
Delay100TCYx(40);
}
// send to position 6, line2 0x9A
// roll
for(i=0;i<5;i++)
{
putcUSART(roll_ascii); // put in array
while(BusyUSART());
Delay100TCYx(40);
}
// send to position 12, line2 0xA0;
// yaw
for(i=0;i<5;i++)
{
putcUSART(yaw_ascii); // put in array
while(BusyUSART());
Delay100TCYx(40);
}
}
Thanks!
And I'm not much of a C programmer, but your numeric conversion routines don't seem to use the loop index to point to an individual character within the array.· For example:
void out_lcd(void) {
· // x position
· // convert to ascii numbers
· // send one by one
· for(i=0;i<5;i++) {
·· ·putcUSART(x_ascii); // put in array
·· ·while(BusyUSART());
·· ·Delay100TCYx(40);
· }
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax