Page 1 of 1

GLK240128-25 with Atmega32

Posted: Mon Nov 02, 2009 11:54 pm
by tbermea
I am attempting to write to the GLK240128-25 LCD using an Atmega32. I have resorted to using CodeVisionAVR C Compiler to help write the program. I am not getting any output on the LCD and have run out of ideas. Below is the code. Please take a look and let me know if there is anything I can change or add to write to the LCD via RS232. Any help is appreciated.

______________________________________

#include <avr/io.h>
#include <stdio.h>


int main(void)
{

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: Off
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 9600
UCSRA=0x00;
UCSRB=0x08;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x25;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;


while (1)
{
//Disable flow control
UDR = 0xFE;
UDR = 0x3B;

//Write letter A to LCD
UDR = 'A';

};
}

Posted: Tue Nov 03, 2009 8:26 am
by Ray
The atmega uses ttl levels for serial communication do you have configured the display for this?

Posted: Tue Nov 03, 2009 11:19 am
by tbermea
Ray wrote:The atmega uses ttl levels for serial communication do you have configured the display for this?
By this configuration do you mean soldering the zero ohm resistors to the TTL jumpers? Or what configuration are you referring to?

Posted: Tue Nov 03, 2009 11:38 am
by Ray
That is indeed what i meant also remove the ones on the rs232 pads.

Posted: Tue Nov 03, 2009 12:55 pm
by tbermea
i want to clarify, I am Using tan Atmega32 developmental kit which contains an RS232 interface on board which I am trying to use. If I were to change the jumpers to TTL , would i be able to use the RS232 interface with my PC or the developmental kit ?????

Posted: Tue Nov 03, 2009 1:24 pm
by Ray
If you can successfully communicate with the atmel from your pc you must leave the jumpers on rs232 mode and not ttl, I coudln't find a datasheet for your devkit so its really hard to validate for me.

To get up and running i suggest communicating with your pc first and when thats up and running switch over to our display.

Posted: Wed Nov 04, 2009 9:16 pm
by tbermea
I finally have the atmega32 sending characters through the hyper terminal. I have attempted writing to the LCD using that same code but there is nothing displayed. I believe it to be a problem with the flow control. This is the new code I am using:

#include <avr/io.h>
#include <avr/delay.h>

int main(void)
{
UCSRB = 0X08; //Enable Transmit
UBRRL = 0x19; //Generate baud rate of 9600 for 4MHz system clock

while(1)
{
UDR=0x41;
while(UCSRA & (1 << TXC));
_delay_ms(200);
}
return 0;
}

_________________________________

When connecting the LCD to the PC via hyperterminal, I set Xon/Xoff (flow control?) . How do I write this to the LCD? What line of code should I use?


Thank you for all your help!

Posted: Thu Nov 05, 2009 12:00 am
by Henry
There is no XON/XOFF flow control in the display. also, in your code you show you are transmitting at 9600, is your display set to 9600?

Posted: Thu Nov 05, 2009 12:56 am
by tbermea
When using the auto detect display option on the the MOGD# software the baud rate is changed to 9600. Does the GLK model have the ability to save that baud rate or does it need to be initialized in code? If so, what commands could be used to send appropriate hex numbers to change the baud rate? Besides the baud rate, is there anything else that needs to be initialized on the LCD in order to write to it? Thanks for your help!

Posted: Thu Nov 05, 2009 7:24 am
by Raquel
I see in your post that your Atmel (via RS232 IC) is able to communicate with the PC, and the GLK240128-25 display is also able to communicate with the PC. When connecting the Atmel to the GLK, make sure that you switch the transmit and receive lines.

The display should be ready to accept data at default 19200 from the factory. But since you want communication at 9600, then that is the only configuration you need to do. You do not have to change the baud rate in your code; you can simply get Mogd# to set (and save) it for you (as I see here that you seem to have successfully done at 9600).

I hope this helps,