Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12455 Discussions

Problem with GRAPHICS LCD Interface (128*64) for cyclone 3c120 device

Altera_Forum
Honored Contributor II
1,061 Views

Hi all, 

 

I'm a novice programmer to interface graphics LCD (glcd) using cyclone iii 3c120 device. 

 

The display is an Optrex part number F-51852GNFQJ-LB-CAN (Green Pixels). 

128 × 64 dot matrix graphics LCD display. 

 

 

 

I'm using Nios II Eclipse IDE to interface glcd with a C language based API. 

 

The C source file is shown below(taken from 24931 post id): 

 

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

 

 

void glcd_writeByte(int DI, int data) 

if (DI == 1) 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_D_CN_BASE, 0x01); //write a command; 

else 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_D_CN_BASE, 0x00); //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_WEN_BASE, 0x00); //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, 0x01); //pull the ENABLE pin high to disable writing to the LCD 

 

 

 

 

void glcd_init(void) 

 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_WEN_BASE, 0x01); 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_D_CN_BASE, 0x01); 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_RSTN_BASE, 0x00); // Hard reset 

usleep(20); // Wait 20us; 

IOWR_ALTERA_AVALON_PIO_DATA(GLCD_RSTN_BASE, 0x01); // 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 

 

 

int main(void) 

 

printf("Graphics LCD Display\n"); 

glcd_init(); 

 

 

 

 

 

 

********************************************* 

GLCD Pin Specs:  

---------------- 

LCD_DATA0: AA4 

LCD_DATA1: AD1 

LCD_DATA2: V8 

LCD_DATA3: AB5 

LCD_DATA4: AE2 

LCD_DATA5: V5 

LCD_DATA6: V6 

LCD_DATA7: AB3 

 

 

LCD_BS1: ??? Parallel Interface Selection* 

 

 

LCD_CSn: AB24 

LCD_D_Cn: D27 

LCD_E_RDn: V7 

LCD_RSTn: H7 

LCD_WEn: AC4 

 

 

LCD_SERn: ??? LCD Parallel/Serial DATA Select* 

 

********************************************* 

 

 

 

My SOPC system contains the following components: 

 

 

  • NIOS II Processor 

  • ON-Chip Memory 256Kb 

  • JTAG UART 

  • LCD_DATA
  • LCD_CSn (1-bit PIO) 

  • LCD_D_Cn (1-bit PIO) 

  • LCD_E_RDn (1-bit PIO) 

  • LCD_RSTn (1-bit PIO) 

  • LCD_WEn (1-bit PIO) 

 

 

 

 

The above code doesn't change my gLCD Display. The display is same even after programming the hardware. 

 

 

Please help me for interfacing gLCD. 

 

 

 

 

 

 

NOTE: * denotes that there are no pin assignments specified as such in Cyclone III Dev Ref Manual. Also I have not assigned pins for the signals such as  

 

  • LCD_BS1 

  • LCD_SERn 

0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
96 Views

TO_BE_DONE

Altera_Forum
Honored Contributor II
96 Views

 

--- Quote Start ---  

 

After run this code, your GLCD will display ALTERA logo.  

 

Any problem u can contact with me. 

--- Quote End ---  

 

 

Hi, 

 

I made all the steps described in this thread but my glcd still doesn't display anything. I know i'm doing something wrong but i don't know what it is. 

 

I used your NIOS program and also used the system described by samratv with that pin assignment. I have the F-51852GNFQJ-LB-AIN (Blue pixels), is that why it doesn't work for me?? 

 

Thnxs
Reply