- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
In order to use the graphic LCD as output monitor, I implemented a nios cpu (with onchip, jtag, and 6 PIO as in and out pins of the LCD) on my FPGA. The problem that I dont have any change in the LCD. The software is: # 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(PIO_D_CN_BASE, 1); //write a command; } else { IOWR_ALTERA_AVALON_PIO_DATA(PIO_D_CN_BASE, 0); //write data; } IOWR_ALTERA_AVALON_PIO_DATA(PIO_DATA_BASE, data); //put DATA on the data lines; usleep(2); //wait 2 us IOWR_ALTERA_AVALON_PIO_DATA(PIO_CSN_BASE, 0); //pull the ENABLE pin low to enable writing to the LCD usleep(2); //wait 2 us IOWR_ALTERA_AVALON_PIO_DATA(PIO_WE_BASE, 0); //pull the Write Enable pin low to enable writing to the LCD usleep(2); //wait 2 us IOWR_ALTERA_AVALON_PIO_DATA(PIO_WE_BASE, 1); //pull the ENABLE pin high to disable writing to the LCD IOWR_ALTERA_AVALON_PIO_DATA(PIO_CSN_BASE, 1); //pull the Write Enable pin high to disable writing to the LCD } void glcd_init(void) { IOWR_ALTERA_AVALON_PIO_DATA(PIO_RE_BASE, 1); // Set all glcd pins HIGH IOWR_ALTERA_AVALON_PIO_DATA(PIO_WE_BASE, 1); IOWR_ALTERA_AVALON_PIO_DATA(PIO_D_CN_BASE, 1); IOWR_ALTERA_AVALON_PIO_DATA(PIO_CSN_BASE, 1); IOWR_ALTERA_AVALON_PIO_DATA(PIO_RST_BASE, 0); // Hard reset usleep(20); // Wait 20us; IOWR_ALTERA_AVALON_PIO_DATA(PIO_RST_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 corre } int main() { printf("Hello from Nios II!\n"); glcd_init(); return 0; }- Tags:
- Nios®
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page