Hi Guys,
I just wanted to test my connections and the LCD itself and I started using Vanya's LC7981 code https://github.com/vsergeev/embedded-drivers/tree/master/avr-lc7981 with slight modifications for 128x128 LCD I'm using. Using an Arduino Mega 2560 board but with GCC C. The LCD lights up and I can control the contrast. The only thing that happens is some flickering. No characters shows up. What could possibly be the problem ?
The constants I changed were,
In lc7981.h,
In lc7981.c,
I just wanted to test my connections and the LCD itself and I started using Vanya's LC7981 code https://github.com/vsergeev/embedded-drivers/tree/master/avr-lc7981 with slight modifications for 128x128 LCD I'm using. Using an Arduino Mega 2560 board but with GCC C. The LCD lights up and I can control the contrast. The only thing that happens is some flickering. No characters shows up. What could possibly be the problem ?
The constants I changed were,
In lc7981.h,
Code:
#define F_CPU 16000000
#define LCD_CTRL_DDR DDRC
#define LCD_CTRL_PORT PORTC
#define LCD_CTRL_RS 1
#define LCD_CTRL_RW 2
#define LCD_CTRL_E 3
#define LCD_CTRL_CS 4
#define LCD_CTRL_RST 5
#define LCD_WIDTH 128
#define LCD_HEIGHT 128
#define lcd_cs_high() (LCD_CTRL_PORT |= (1<<LCD_CTRL_CS))
#define lcd_cs_low() (LCD_CTRL_PORT &= ~(1<<LCD_CTRL_CS))
#define lcd_rst_high() (LCD_CTRL_PORT |= (1<<LCD_CTRL_RST))
#define lcd_rst_low() (LCD_CTRL_PORT &= ~(1<<LCD_CTRL_RST))
Code:
/**
* Initializes the LCD in graphics mode.
* Uses a character pitch of 8 (8 bits are plotted whenever a byte is drawn)
*/
void lcd_graphics_init(void) {
unsigned char commandData;
/* Set the data direction registers appropriately */
LCD_DATA_DDR = 0xFF;
LCD_CTRL_DDR |= (1<<LCD_CTRL_RS)|(1<<LCD_CTRL_RW)|(1<<LCD_CTRL_E)|(1<<LCD_CTRL_CS)|(1<<LCD_CTRL_RST);
/* Assert all control lines to low */
lcd_rw_low();
lcd_rs_low();
lcd_enable_low();
lcd_cs_low(); /* Active */
lcd_rst_high();
delay_ms_long(100);
lcd_rst_low();
delay_ms_long(100);
/* Send mode configuration command with
* Toggle Display On, Master, Mode Graphics bits set */
commandData = LCD_MODE_ON_OFF | LCD_MODE_MASTER_SLAVE | LCD_MODE_MODE;
lcd_write_command(LCD_CMD_MODE, commandData);
/* Send the set character pitch command with horizontal
* character pitch of 8 (so 8 pixels are painted when we draw) */
commandData = LCD_CHAR_PITCH_HP_8;
lcd_write_command(LCD_CMD_CHAR_PITCH, commandData);
/* Send the number of characters command with the total
* number of graphics bytes that can be painted horizontally
* (width/8) */
commandData = (LCD_WIDTH/8)-1;
lcd_write_command(LCD_CMD_NUM_CHARS, commandData);
/* Set the time division */
commandData = 128-1;
lcd_write_command(LCD_CMD_TIME_DIVISION, commandData);
/* Set the display low/high start address to 0x00 (left corner) */
commandData = 0x00;
lcd_write_command(LCD_CMD_DISPLAY_START_LA, commandData);
lcd_write_command(LCD_CMD_DISPLAY_START_HA, commandData);
/* Reset the cursor to home 0x00 (left corner) */
commandData = 0x00;
lcd_write_command(LCD_CMD_CURSOR_LA, commandData);
lcd_write_command(LCD_CMD_CURSOR_HA, commandData);
}
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
Last edited: