FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5925 Discussions

Graphics LCD problem with Cyclone III FPGA Development Kit

Altera_Forum
Honored Contributor II
1,165 Views

Can anybody help me: I have battled for a while to get the 128x64 graphics lcd on the Cyclone III working. I eventually got it working, but used seperate PIO pins, seeing that i could not get hold of an IP core that is supported by the HAL. Anyway, here is the code i used for initializing the LCD: 

 

void glcd_init(void) 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_REN_BASE, 1); // Set all glcd pins HIGH 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_WEN_BASE, 1); 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_D_CN_BASE, 1); 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_EN_BASE, 1); 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_RSTN_BASE, 0); // Hard reset 

usleep(20); // Wait 20us; 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_RSTN_BASE, 1); // Release reset; 

usleep(100000); // Wait 100ms); 

glcd_writeByte(0, 0xe2); // Internal Reset 

glcd_writeByte(0, 0xa2); // Bias = 1/9; 0xa3 for 1/7 

glcd_writeByte(0, 0xa1); // ADC = 1 (right to left); 0xa0 for 0(left to right) 

glcd_writeByte(0, 0xc0); // Common direction = Normal; 0xc1 for inverse 

glcd_writeByte(0, 0x28); // Set Power Control - Internal power circuits OFF ******* but looks better with 0x2f 

glcd_writeByte(0, 0xe7); // Set Driver ON; 0xe6 for OFF 

glcd_writeByte(0, 0xaf); // Display ON; 0xae for OFF 

glcd_writeByte(0, 0xa5); // Entire Display ON - Turn ON all pixels (irrespective of RAM) 

usleep(500000); // Wait 500ms 

glcd_writeByte(0, 0xa4); // Entire Display NORMAL - Pixels correspond to display RAM 

 

The code works perfectly and I can even turn pixels on and off anywhere on the display. The problem however is that when i switch a pixel on, the rest of that column also lights up slighty (but is definately not on). It is annoying because when i draw graphics on the lcd, it looks like there are ghost images next to the graphics i am drawing. I suspected that it could be something to do with the supply voltages V1 to V5 that the board provides to the LCD, but they seem within range according to the datasheet - and besides - surely Altera double checked these values before building the board. I would really appreciate any help. I have tried contacting the people from Altera that our university normal deals with, but i havent had a single reply from Altera yet. Just as a matter of curiosity - do any of you deal with Xilinx products and what are their support like? 

0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
253 Views

Hi, 

 

I was also looking to use the graphics LCD in Stratix III. Good to see your post. I saw that same Graphics LCD is used in Cyclone III as well as Stratix III. 

I wanted to ask a few questions regarding how to make it work. 

Here is what I did after seeing your example ... In the standard NIOS example, I did the following things... 

1) In SOPC builder, I put 6 different PIO ports - oled_data (8 bits), oled_csn(1 bit), oled_d_cn(1 bit), oled_e_rdn(1 bit), oled_rstn(1 bit), oled_wen(1 bit).  

2) synthesized the whole thing in quartus and programmed to Stratix III. 

3) Used eclipse, and the program is the following, which i modified  

# include <stdio.h># include <unistd.h># include "system.h"# include "altera_avalon_pio_regs.h" 

 

int main() 

printf("Hello from Nios II!\n"); 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_E_RDN_BASE, 1); // Set all glcd pins HIGH 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_WEN_BASE, 1); 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_D_CN_BASE, 1); 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_CSN_BASE, 1); 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_RSTN_BASE, 0); // Hard reset 

usleep(20); // Wait 20us; 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_RSTN_BASE, 1); // Release reset; 

usleep(100000); // Wait 100ms); 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xe2); // Internal Reset 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xa2); // Bias = 1/9; 0xa3 for 1/7 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xa1); // ADC = 1 (right to left); 0xa0 for 0(left to right) 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xc0); // Common direction = Normal; 0xc1 for inverse 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0x28); // Set Power Control - Internal power circuits OFF ******* but looks better with 0x2f 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xe7); // Set Driver ON; 0xe6 for OFF 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xaf); // Display ON; 0xae for OFF 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xa5); // Entire Display ON - Turn ON all pixels (irrespective of RAM) 

usleep(500000); // Wait 500ms 

usleep(500000); 

IOWR_ALTERA_AVALON_PIO_DATA(OLED_DATA_BASE, 0xa4); // Entire Display NORMAL - Pixels correspond to display RAM 

 

return 0; 

 

I couldn't see any change in the graphics LCD panel...it is always light with blue light and it stays same... 

can u tell what I might have done wrong.. 

 

thanks  

pramod
0 Kudos
Altera_Forum
Honored Contributor II
253 Views

Your problem is that you replaced my glcd_write() parts of the code by directly writing to the port pins. This is the crucial initializing step and should be done as i did in my code using the following glcd_write() function: 

 

void glcd_writeByte(int DI, int data) 

if (DI == 1) 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_D_CN_BASE, 1); //write a command; 

else 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_D_CN_BASE, 0); //write data; 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_DATA_BASE, data); //put DATA on the data lines; 

usleep(2); //wait 2 us 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_EN_BASE, 0); //pull the ENABLE pin low to enable writing to the LCD 

usleep(2); //wait 2 us 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_WEN_BASE, 0); //pull the Write Enable pin low to enable writing to the LCD 

usleep(2); //wait 2 us 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_WEN_BASE, 1); //pull the ENABLE pin high to disable writing to the LCD 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_EN_BASE, 1); //pull the Write Enable pin high to disable writing to the LCD 

 

This should then work. Just another thing: the data pins should actually be bi-directional pins to allow reading from the GLCD as well - just thought i will mention it. 

 

I would like to know if this works with your display and what the display looks like after you have initiallized it. 

 

 

0 Kudos
Altera_Forum
Honored Contributor II
253 Views

hi,  

 

that code perfectly ... the LCD changed from default all blue background to  

now spots of light blue and dark blue all over the LCD... 

is that what you also got ... 

 

what should I do if I have to display some picture or some name ... 

how should I pass the data ... 

 

thanks for your function glcd_writeByte .. it worked beautifully.. 

 

pramod
0 Kudos
Altera_Forum
Honored Contributor II
253 Views

I have done this project perfect. Have a look at 

http://alteraforums.com/forum/showthread.php?t=29471&highlight=glcd
0 Kudos
Reply