Interfacing Graphical LCD with AVR MCU – Part II

This tutorial deals with downloading and installing ProGFX
graphic engine. ProGFX is a
free and easy to use embedded graphic library that can control several display
modules and can run on AVR, PIC and ARM MCUs. In this tutorial we will make
a ProGFX graphical application
with Atmel AVR ATmega32 MCU using AVR Studio and WinAVR (C Compiler). So lets
begin.

The First screen shown up after the AS6 has started is the Start Page. The start page helps you quickly create a new project or load your previous project without wasting much time.

Atmel Studio 6 Home Screen

To create a new project we select New Project … option from the Start Page.

AS6 will show you the New Project Wizard as shown in the above image. From the project template area (Installed Templates) select C/C++ as the project template. From the project type area select “C Executable Project” . After that fill out the project details at the bottom like project name, its location on your PC etc. Finally Hit OK.

Name the project: hello_graphics

Next to the project detail window comes the Device Selection Window. That lets you choose the target MCU for your project. For GLCD projects we will use ATmega32, so select that from the device list.

Device Selection (ATmega32 in this case)

After we completed the “New Project” wizard, we are presented with the Atmel Studio 6 main window. So let us get introduced with the various parts of Atmel Studio 6 window.

The Menu Bar – Common in all application. This has commands for all tasks organized in sub menus like File , Edit, View etc.

The Tool Bar – It is also common in all application. The tool bar has selected commands from the Menu Bar which the user uses often. They have small icons for each command.

The Main Source Editor – This window is the main editor for the source files in the current project. you can load any file (in your current project) by double clicking it in the solution explorer (discussed shortly). The editor has spell check and auto complete features.

Solution Explorer – In AVR Studio 6 a solution can house one or more projects. In our case we simply keep one project per solution. Solution Explorer is discussed in more detail in next section.

Output Window – Most build tools like the compiler, linker etc are command line tools. When we issue command such as the Build command, their output is captured and shown in this area. Also errors or warning if any are also shown in this area.

The next very important thing you need to do is to configure the project. Some people thinks the program is a self contained entity. But this is wrong.

One another configuration required in project at which the target processor is running. Since Atmel AVR microcontrollers can be clocked from a variety of clock sources and can be made to run at any speed below 16MHz (newer AVRs can be clocked upto 20MHz!). So we must tell the compiler at what speed our chip is running to that it (the compiler) can calculate delays properly.

This is defined as a preprocessor symbol.

Don’t worry much about the name if you can’t get it. Simply understand it like a constant which is available in all you C source files in the project.

A preprocessor symbol has a name like F_CPU (which stands for frequency of the CPU) and a value like 16000000 (16MHz)

It can be defined using the project properties dialog.

To bring up the project properties dialog you can do any one of the following.

Once you have opened the project properties dialog. Navigate as shown in the image below.

This will open up the following dialog, where you can enter the symbol F_CPU and its value 16000000.

All of our AVR development boards are clocked using a 16MHz external crystal so we have defined F_CPU=16000000

Next we will setup our project so that compiler can find include and library files of ProGFX.

Setting up include path

Similarly add folder for the library (lib)

The final step is the building the project. It means compiling all the c source files in the project to generate machine code file (.o files, or object files) and then finally linking all object files to generate the executable file (.hex) file. This hex file is ready to be loaded into the microcontroller chip.

To build the project, select Build Solution from the Build menu. You can also use keyboard shortcut F7 to build the project.

Double Click On the "HelloGraphics.c" from the project file area
on the LEFT hand side of AVR Studio. You will be presented with a blank file.
Just copy/paste the code given below.

After entering code save the file. Then from the "Build"
menu select "Rebuild All". If you did every
steps carefully then the project will compile without any problem and you will
be get a HEX file. The hex file is found inside the "default"
folder inside your project folder. In this case the file should be "HelloGraphics.hex".
You can program this hex file to the MCU using any standard
ISP Programmer.

The hardware required to run this project is described in detail in
the following tutorial.

About: ProGFX is a free project started by eXtreme
Electronics India to promote use of graphical modules in new embedded
projects. The development of ProGFX project requires money and LOTs of time.
So please buy Graphical
LCD Modules from our online store to help us in return.
Currently these modules are only supplied within India.

60 thoughts on “Interfacing Graphical LCD with AVR MCU – Part II”

Hello sir,
first of all I congratulates and thank u for your great and successful contribution in the field of embedded system.
I was eagerly waiting for this project and its very nicely explained.
Sorry in advance, but I want to ask you that how actually we are writing any words in GLCD. We are directly using the library function to write anything. I want to know exactly how things are going on just like you have explained for simple LCD, if possible.
Anywayz, thank you again for your help.

Hello Sir,
Thank you very much for these tutorials about AVR, and i have a question about this one. Can i use this ProGFX with Codevision, winavr compiler?, if yes how to do it. Thank you again for your help and your courses.

Hi Avinash ,
You have an awesome website and easily the best AVR tutorial on the internet . I have one question regarding the GLCD library . Is it possible to change the port connections ? For example , I want to connect my data pins to Port B instead of Port C . Thanx for the help !!

try running the pre-compiled hex file. Make sure you use ATmega32 only.
Also confirm that a valid font is selected.

By nikhil
-
January 18, 2012 2:47 pm

ohh..coz i was using an atmega16 …thankz a lot

By Hemant Jha
-
April 14, 2012 5:57 pm

Hi Avinash,

I am using ATmega32A, if i burn the “HelloGraphics.hex” file or any readymade hex file provided by you , I get a continuous buss from the buzzer of my development board and nothing happens on the GLCD.

Could you please help me understand why is there a problem like this ?

Did i make any mistakes?

By Avinash
-
April 15, 2012 9:22 am

@Hemant Jha ,

Why do u guys make me supper irritate ?

U guys now nothing about the what you are doing and then ask me silly questions!!!

If u can’t even do experiments given in this site only one that can help you is GOD !!!

You guys buy crap development board from other vendor and try to run our code !!! Go ask the guy who sold u the crap ! I don’t have free time.

By Hemant Jha
-
April 15, 2012 10:35 am

Hello Avinash,

Thanks for such a cordial response. Your response says everything about you as a person. I have seen some of your posts where you have been very arrogant and harsh dealing with other people interacting with you. Yesterday when I called you at your office … you were equally rude.

Just a small word of advise which will definitely help you in future .. “People with real expertise, intellect and talent are not and need not be arrogant”.

BTW – I teach system designing to some of the worlds best technology companies that a person can think of … but I have no shame in saying that I was experimenting with GLCD for the first time and I am not a expert of the same and I dont mind saying that I dont know certain things in this world.

Thanks and Regards,

Hemant Jha

By Avinash
-
April 15, 2012 12:09 pm

@Hemant Jha,

I cannot “please” every people every time, that was what I was taught at my school ! What ever you think of me ! I don’t like peoples creating problems out of nowhere ! Remember that not all people are compatible in this world ! I say what I like, don’t add much cheese! Bye 🙁

Sir,
I am working on a fingerprint based attendence system using SM-630 module.
I tested it successfully with atmega16 and 16×2 LCD.
Even i a made an efficient fingerprint library to interface with SM-630 module that can add,delete and store fingerprints, using Extreme UART library.

Now i am using atmega128 and graphic lcd to make it more of my Major project.

Graphic LCD Connections
=======================
Data -PORT A (D0:D7,PIN0:PIN7)
CS1- C2
CS2- C7
RST- C6
RS- C5
RW- C4
E- C3
I have made my pcb.
Please i need pro-gfx configured to upper configuration as my other pins are used for ethernet and sensor and keypad.
Kindly help.Please guide.
And there is a need of software uart library in hobby electronics for AVR,its not available online.You(avinash sir) always have made unique and easy to use libraries n tools not available online.Kindly take this into your consideration

sir i will use avr studio5 . i am unable to use profix library in my project ,
how to use this library in avr studio5 pl.help me
i recent purchase 2nos glcd from extreme electronics store .. your code work fine but new project cant compile with library..

Dear Friends,
Thank you very much for this library and tutorial. I want to ask something about porting this library to be used with MSP430 chips (TI devices). I’m doing some tutorials and stuff at spanish language at my blog, and this library is important to be promoted in the community, that’s why my interest on using it with other microcontrollers. Thanks!

@Prashan ok if you are NOT able to do it your self you can get help from me by paying the proper amount. Everything I could do for free is written above! If you need any more you have to pay, other wise I have no free time.

sir, i bought glcd from u…and i am using it to interface with atmega32………sir i want to ask is it necessary to give it 16MHz frequency…….can we give it 1MHz frequency………..pls help me…..
sir these tutrial have been very useful in studying glcd and helpful for other projects

please remember the spelling of “You” is Y O U and NOT u ! Your comment will be deleted in 24 hours !

And why are you asking what is necessary and what is NOT? is their any problem following everything I say?

Why the hell you wanna use 1MHz if I told to use 16MHz ? Are you used to failures or in love with them? Their os NO point in asking such silly things ! If tutorials says use 16MHz use 16MHz without any questions !

I have stopped writting much because of few mad peoples here in India.

Now I will share works only with selected peoples.

By Deepak Nair
-
January 1, 2015 12:25 pm

I hope you will include me in your list of “selected people!”

Regards.

Deepak Nair

By Deepak Nair
-
January 6, 2015 11:10 am

Hello Avinash,

Thank you so much for demonstrating how to use the GLCD with AV6. Although I have yet to come to grips with the procedure (complex for me), I have been able to modify your sample program for my project.

Actually, I am working on a humanoid robot and wish to use the GLCD module for the animated face. So far, I have been able to make good progress, thanks to you!

I know it would mean a lot of work for you, but a tutorial on using the GLCD with AV6 would be appreciated by many of your fans.