mgbglasgow
Junior Member level 1
- Joined
- Jun 15, 2011
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,508
hi all,
have lcd module thats is not 44780, have code that worked with that, now new lcd module that suggests it is compliant seems not to be, data sheet is very weak. Any one any experience using this type of controller. Wait/Timing commands are questionable.
Basically looking for explanation of differences to timings/commands, i will write a driver for it (hack the 44780 code basically!)
controller is **broken link removed**
lcd unit via RS uk is https://uk.rs-online.com/web/p/lcd-monochrome-displays/7436144/
code is standard:
/*
*
*
*/
#ifndef _XTAL_FREQ
// Unless specified elsewhere, 4MHz system frequency is assumed
#define _XTAL_FREQ 8000000
#endif
#include <htc.h>
#include "lcd.h"
#define LCD_RS RA5
#define LCD_RW RA0
#define LCD_EN RA4
#define LCD_DATA PORTB
#define LCD_STROBE() ((LCD_EN = 1),__delay_us(10),(LCD_EN=0))
/* write a byte to the LCD in 4 bit mode */
void
lcd_write(unsigned char c)
{
__delay_us(100);
LCD_DATA = ( ( c >> 4 ) & 0x0F );
LCD_STROBE();
LCD_DATA = ( c & 0x0F );
LCD_STROBE();
}
/*
* Clear and home the LCD
*/
void
lcd_clear(void)
{
LCD_RS = 0;
lcd_write(0x1);
__delay_ms(2);
}
/* write a string of chars to the LCD */
void
lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}
/* write one character to the LCD */
void
lcd_putch(char c)
{
LCD_RS = 1; // write characters
lcd_write( c );
}
/*
* Go to the specified position
*/
void
lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80+pos);
}
/* initialise the LCD - put into 4 bit mode */
void
lcd_init()
{
char init_value;
ADCON1 = 0x06; // Disable analog pins on PORTA
init_value = 0x30;
TRISA=0;
TRISB=0;
TRISC=0;
PORTB = 0;
LCD_RS = 0;
LCD_EN = 0;
__delay_ms(50); // wait at least 15mSec after power applied,
PORTB = 0x30;// load PortB with 0x30
__delay_us(10); //allow to stabilise
LCD_STROBE(); // pulse EN high to load
__delay_ms(5); //allow time>4.1 ms
PORTB = 0x30; //reload PortB with 0x30
__delay_us(10); //allow to stabilise
LCD_STROBE(); // pulse EN high to load
__delay_us(120); //allow time>100 us
PORTB = 0x30; //reload PortB with 0x30
__delay_ms(5); //allow to stabilise
LCD_STROBE(); // pulse EN high to load
__delay_us(10); //allow time>100 us
PORTB = 0x20; // Four bit mode
__delay_us(10); //allow to stabilise
LCD_STROBE();
__delay_ms(150);
PORTB = 0x20; // Four bit mode
LCD_STROBE();
__delay_ms(150);
lcd_write(0x0F); // Display On, Cursor On, Cursor Blink
lcd_clear(); // Clear screen
lcd_write(0x06); // Set entry Mode
}
Steve in glasgow
have lcd module thats is not 44780, have code that worked with that, now new lcd module that suggests it is compliant seems not to be, data sheet is very weak. Any one any experience using this type of controller. Wait/Timing commands are questionable.
Basically looking for explanation of differences to timings/commands, i will write a driver for it (hack the 44780 code basically!)
controller is **broken link removed**
lcd unit via RS uk is https://uk.rs-online.com/web/p/lcd-monochrome-displays/7436144/
code is standard:
/*
*
*
*/
#ifndef _XTAL_FREQ
// Unless specified elsewhere, 4MHz system frequency is assumed
#define _XTAL_FREQ 8000000
#endif
#include <htc.h>
#include "lcd.h"
#define LCD_RS RA5
#define LCD_RW RA0
#define LCD_EN RA4
#define LCD_DATA PORTB
#define LCD_STROBE() ((LCD_EN = 1),__delay_us(10),(LCD_EN=0))
/* write a byte to the LCD in 4 bit mode */
void
lcd_write(unsigned char c)
{
__delay_us(100);
LCD_DATA = ( ( c >> 4 ) & 0x0F );
LCD_STROBE();
LCD_DATA = ( c & 0x0F );
LCD_STROBE();
}
/*
* Clear and home the LCD
*/
void
lcd_clear(void)
{
LCD_RS = 0;
lcd_write(0x1);
__delay_ms(2);
}
/* write a string of chars to the LCD */
void
lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}
/* write one character to the LCD */
void
lcd_putch(char c)
{
LCD_RS = 1; // write characters
lcd_write( c );
}
/*
* Go to the specified position
*/
void
lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80+pos);
}
/* initialise the LCD - put into 4 bit mode */
void
lcd_init()
{
char init_value;
ADCON1 = 0x06; // Disable analog pins on PORTA
init_value = 0x30;
TRISA=0;
TRISB=0;
TRISC=0;
PORTB = 0;
LCD_RS = 0;
LCD_EN = 0;
__delay_ms(50); // wait at least 15mSec after power applied,
PORTB = 0x30;// load PortB with 0x30
__delay_us(10); //allow to stabilise
LCD_STROBE(); // pulse EN high to load
__delay_ms(5); //allow time>4.1 ms
PORTB = 0x30; //reload PortB with 0x30
__delay_us(10); //allow to stabilise
LCD_STROBE(); // pulse EN high to load
__delay_us(120); //allow time>100 us
PORTB = 0x30; //reload PortB with 0x30
__delay_ms(5); //allow to stabilise
LCD_STROBE(); // pulse EN high to load
__delay_us(10); //allow time>100 us
PORTB = 0x20; // Four bit mode
__delay_us(10); //allow to stabilise
LCD_STROBE();
__delay_ms(150);
PORTB = 0x20; // Four bit mode
LCD_STROBE();
__delay_ms(150);
lcd_write(0x0F); // Display On, Cursor On, Cursor Blink
lcd_clear(); // Clear screen
lcd_write(0x06); // Set entry Mode
}
Steve in glasgow