LK204-25 programming

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

Moderators: Henry, Mods

Post Reply
Macabra
LCD?
Posts: 7
Joined: Wed Sep 10, 2008 2:04 am

LK204-25 programming

Post by Macabra »

Hi,

I finally got the LCD to communicate with my PIC. I have it the PIC connected to a MAX3232 chip which converts TTL signals to RS232 and from there I have it connected to the serial interface of the LCD. I've been working on this issue for almost a week now and I still can't figure out why the heck is it that the top left character of the Matrix Orbital logo prints through the screen infinitely!! :o . All I am really doing is powering it up and the character just runs through the entire screen all the time. Please, let me know what the heck is wrong. I've tried lots of things and I can't make this LCD to work.

The following is the code which isn't much:

#include <p24hj12gp201.h>
#include <stdlib.h>
#include <stdio.h>
#include <uart.h>
#include "LCD_Uart.h"

int main ()
{
initUart1();
//LCDinit();

while(1)
{
putcUART1(254);
putcUART1(88); //doesn't matter what command I put, it won't do it
}
}
Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Macabra,

Sorry to hear you are having trouble interfacing that PIC to your LK204-25. It sounds like a character is being sent repeatedly to the display, and if I'm not mistaken, it is the hex value '0'.

Not quite sure what it is, but somehow it seems '0' is being output continuously. Try to take another look at the controller code, and make sure you've got Tx on the PIC wired up to Tx on the display.

My guess is that it's getting stuck in the infinite loop at the bottom there, and for some reason doesn't like the commands. Try a putc of 65, 41, and A, and run it through once or twice rather than infinitely. I'm not very familiar with putc so I'm wondering if it doesn't like those non-character values.

If you make any progress, or run into any more trouble, please post up here and I'll do my best to steer you in the right direction.

Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital
Macabra
LCD?
Posts: 7
Joined: Wed Sep 10, 2008 2:04 am

Post by Macabra »

Thank you Troy for your quick response! :)

The thing is that it does that even when I am not running the code whatsoever..not even for the first time. Before I even compile, the character there runs across the screen.

I checked the wires and connections they are good. I only have the ground connected to the other ground and TX from host connected to pin 2(RX) of LCD.

I connected the TX too now (don't see the necessity for this in this case) and it stopped writing but it is frozen with those characters there but with a mix of candy cane looking characters. :cry:

I'm using a PIC microcontroller (PIC24) and sending serial signals through the UART commands. I could post the header if you believe that is the source of the problem. I've tried clearing the screen and it does nothing either..even turning it off through software sending commands doesn't turn it off. =/
Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Macabra,

No worries, good to see the post has given you a few ideas. I notice you mention wiring the controller Tx to the display Rx. While that definitely makes sense, the display is labeled such that Tx goes to Tx, and Rx to Rx. That's the point I was trying to make earlier; you were right to assume wiring up the receive won't really help the problem at this stage.

In theory, we figured the design would aid in correct wiring, but in practice it can definitely be confusing. Try switching your connection and let me know if you are still having trouble.

Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital
Macabra
LCD?
Posts: 7
Joined: Wed Sep 10, 2008 2:04 am

Post by Macabra »

ok, I did switched the inputs on the back of LCD and the character just runs on continuously =/. I suppose that is how I had it originally then. So now I have the TX coming from the PIC (or MAX3232) to TX pin of LCD(pin 3).
Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Macabra,

That connection now sounds right, unfortunately, it looks like you are still getting a value of zero on that Tx line to cause the repeating character.

I'd recommend double checking the settings on the controller. The display will be expecting RS232 levels, unless the protocol jumpers have been changed, so you'll want to make sure that's what the controller is outputting. The communication settings will be 8 data, No parity, 1 stop bit, with flow control turned off.

Other than that, if it's possible, I'd recommend scoping the output from the controller, with and without the display hooked up to see exactly what is being output.

If you do continue to have trouble, just post up any progress you've made and I'll try to help you troubleshoot further.

Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital
.Macabra
LCD?
Posts: 3
Joined: Fri Sep 19, 2008 8:52 pm

Post by .Macabra »

Thank you Troy!

I've checked my code and yes, I have set up everything correctly. here's the code segment:

PLLFBD=38; // M=40
CLKDIVbits.PLLPOST=0; // N1=2
CLKDIVbits.PLLPRE=0; // N2=2
RCONbits.SWDTEN=0; // Disable Watch Dog Timer
//while(OSCCONbits.LOCK!=1) {}; // Wait for PLL to lock
U1MODEbits.STSEL = 0; // 1-stop bit
U1MODEbits.PDSEL = 0; // No Parity, 8-data bits
U1MODEbits.ABAUD = 0; // Autobaud Disabled
U1MODEbits.BRGH = 0; // Low Speed mode
U1BRG = BRGVAL; // BAUD Rate Setting for 19200
U1STAbits.UTXISEL1 = 0;
U1MODEbits.UARTEN = 1; // Enable UART
U1STAbits.UTXEN = 1; // Enable UART Tx
U1MODEbits.RTSMD = 1; // sets to Simplex no Flow Control

This is actually a function that is called upon when InitUart1(); is called in the code. So it sets those bits for transmission. Last week I had the problem in which it wouldn't type anything to the LCD and that was because I was missing that line in the code and now that I added it it does what it does now.

I have not messed with the LCD so it is at it's default setting. However somehow i managed to send the code that deletes the startup screen. I'm referring to the following code sent:

putcUART1(254);
putcUART1(64);
OutStr("testing");

now I don't know how it happened but now every time I turn on the LCD the usual Matrix Orbital logo is gone and was replaced by this weird characters..the whole screen is covered with them. I guess the code did went thguh somehow..though it didn't print out "testing" at all..and some reason I got these weird "s" in black boxes all over the screen.

I read through the manual of resetting the manual default by putting that jumper on the back. I wrote the code to set it to set default baud rate, brightness, etc and save it. It didn't do it. Though the baud rate and brightness is fine, the thing now is that I have those weird characters as my startup screen and I have not been able to replace it again... :o ???...I'm really at a loss here =(

I'm going to check the output of the TTL to RS232 chip..i'm expecting some voltage ranges from -8 V to 8 V and jumping around like that..i'll post updates.

Much thanks for help you are giving me Troy, I really hope we can resolve this =(
.Macabra
LCD?
Posts: 3
Joined: Fri Sep 19, 2008 8:52 pm

Post by .Macabra »

I've been playing with it more and no matter what character i send to it it just prints that corner of the Matrix Orbital logo or "0" as you mentioned. I'm positive it is not the baud rate problem because i connected it to the PC and the LCD works perfectly fine. On my code I configured for 19200 and set no flow control and the rest as stated on previous post.

Geesh this is giving me a very hard time :(

The microcontroller I'm using just for reference is the PIC24HJ12GP.
Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Macabra,

Sorry to hear you are still having some trouble with your micro controller. I appreciate the code post, it may help one of our users diagnose your problem.

Unfortunately, I'm primarily display support, and it looks like the problem right now lies with the controller. I'd suggest scoping out the pins to see what is being transmitted, and speaking to a support representative for that PIC.

I did, however, take a look at the manual for that device, and do have a couple ideas to offer.

First up, I noticed that there are a few settings that require two bits, looks like only one is being set in some cases, not sure if that will be a problem. Second, probably most important, I don't see an initialization for IREN in your code. From what I have read, if this pin is enabled the Tx line will idle, which could be causing your trouble.

Again, I'm no PIC expert, so take a look for yourself, and get in contact with the PIC support folks if need be. Wish I could be more help, but if you do run into any more display questions, just let me know.

~Troy
Troy Clark
Design & Development
Matrix Orbital
Post Reply