void Initialize_LCD(void){
	int8 i;

	TRIS_RS=0;
	TRIS_E=0;


	RS_PIN=0;
	E_PIN=0;


	TRIS_DATA_PIN_4=0;
	TRIS_DATA_PIN_5=0;
	TRIS_DATA_PIN_6=0;
	TRIS_DATA_PIN_7=0;

	_delay_5ms();//15ms
	_delay_5ms();
	_delay_5ms();

	for(i=0 ;i < 3; i++){
		lcd_send_nibble(0x03);
		_delay_5ms();//5ms
  	}

	lcd_send_nibble(0x02);

	for(i=0; i < sizeof(LCD_INIT_STRING); i++){
		lcd_send_byte(0, LCD_INIT_STRING[i]);

	}
}
Beispiel #2
0
void lcd_init(void) 
{
   BYTE i;

 #if defined(__PCB__)
   set_tris_lcd(LCD_OUTPUT_MAP);
 #else
  #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
   output_drive(LCD_DATA4);
   output_drive(LCD_DATA5);
   output_drive(LCD_DATA6);
   output_drive(LCD_DATA7);
  #else
   lcdtris.data = 0x0;
  #endif
   lcd_enable_tris();
   lcd_rs_tris();
   lcd_rw_tris();
 #endif

   lcd_output_rs(0);
   lcd_output_rw(0);
   lcd_output_enable(0);
    
   delay_ms(15);
   for(i=1;i<=3;++i)
   {
       lcd_send_nibble(3);
       delay_ms(5);
   }
    
   lcd_send_nibble(2);
   for(i=0;i<=3;++i)
      lcd_send_byte(0,LCD_INIT_STRING[i]);
}
Beispiel #3
0
void lcd_sendByte(uint8_t c){

	uint8_t x;
	x = c >> 4;
	lcd_send_nibble(x);
//	chThdSleepMicroseconds(50);
	lcd_pulsen();
	
	x = c & 0x0f;
	lcd_send_nibble(x);
//	chThdSleepMicroseconds(50);
	lcd_pulsen();

}
void lcd_init() {
    BYTE i;
    set_tris_lcd(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;
    delay_ms(15);
    for(i=1;i<=3;++i) {
       lcd_send_nibble(3);
       delay_ms(5);
    }
    lcd_send_nibble(2);
    for(i=0;i<=3;++i)
       lcd_send_byte(0,LCD_INIT_STRING[i]);
}
Beispiel #5
0
//---------------------------------------- 
// Send a byte to the LCD. 
void lcd_send_byte(char address, char n) 
{ 
	output_low(LCD_RS); 
	
	#ifdef USE_LCD_RW 
	while(bit_test(lcd_read_byte(),7)) ; 
	#else 
	delay_us(60);  
	#endif 
	
	if(address) 
	   output_high(LCD_RS); 
	else 
	   output_low(LCD_RS); 
	      
	 delay_cycles(1); 
	
	#ifdef USE_LCD_RW 
	output_low(LCD_RW); 
	delay_cycles(1); 
	#endif 
	
	output_low(LCD_E); 
	
	lcd_send_nibble(n >> 4); 
	lcd_send_nibble(n & 0xf); 
} 
Beispiel #6
0
void lcd_send_byte(int8 address, int8 n){

	RSPIN=0;

#ifdef USE_RW
	while((lcd_read_byte()&0x80)==0x80);
#else
	_delay_100us();
#endif

	TRIS_DATA_PIN_4=0;
	TRIS_DATA_PIN_5=0;
	TRIS_DATA_PIN_6=0;
	TRIS_DATA_PIN_7=0;

	if(address)
		RSPIN=1;
	else
		RSPIN=0;

	Nop();

#ifdef USE_RW
	RWPIN=0;
	Nop();
#endif

	lcd_send_nibble(n >> 4);
	lcd_send_nibble(n & 0xf);
}
Beispiel #7
0
void lcd_send_byte( unsigned char address, unsigned char n ) {
   PIN_LCD_RS = 0;
   LCD_DELAY();
   PIN_LCD_RS = address;
   ClrWdt();
   PIN_LCD_E = 0;
   lcd_send_nibble(n >> 4);
   lcd_send_nibble(n & 0xf);
}
Beispiel #8
0
/*
 * General Initialization	Example Initialization
 * 1	Wait 20ms for LCD to power up
 * 2	Write D7-4 = 3 hex, with RS = 0
 * 3	Wait 5ms
 * 4	Write D7-4 = 3 hex, with RS = 0, again
 * 5	Wait 200us
 * 6	Write D7-4 = 3 hex, with RS = 0, one more time
 * 7	Wait 200us
 * 8	Write D7-4 = 2 hex, to enable four-bit mode
 * 9	Wait 5ms
 * 10	Write Command "Set Interface"	Write 28 hex (4-Bits, 2-lines)
 * 11	Write Command "Enable Display/Cursor"	Write 08 hex (don't shift display, hide cursor)
 * 12	Write Command "Clear and Home"	Write 01 hex (clear and home display)
 * 13	Write Command "Set Cursor Move Direction"	Write 06 hex (move cursor right)
 * 14	--	Write 0C hex (turn on display)
 * Display is ready to accept data.
 */
void lcd_init() {
    uint8_t count;
    lcd_init_io();
    delay_ms(20);
    lcd_rs_pin = LCD_RS_COMMAND;
    lcd_rw_pin = LCD_RW_WRITE;
    lcd_en_pin = LCD_EN_LOW;
    for(count = 0; count < 3; count++) {
        lcd_send_nibble(0x03);
        delay_ms(5);
    }
    lcd_send_nibble(0x02);
    delay_ms(5);
    lcd_command(LCD_CMD_FUNCTION_SET | LCD_CMD_FUNCTION_SET_2LINE_MODE);
    lcd_command(LCD_CMD_DISPLAY_CONTROL | LCD_CMD_DISPLAY_CONTROL_ON| LCD_CMD_DISPLAY_CONTROL_BLINK | LCD_CMD_DISPLAY_CONTROL_UNDERLINE);
    lcd_command(LCD_CMD_CLEAR_DISPLAY);
    lcd_command(LCD_CMD_ENTRY_MODE | LCD_CMD_ENTRY_MODE_INCREMENT);
}
void lcd_init(void) 
{ 
int8 i; 

lcd_line = 1; 

output_low(LCD_RS); 

#ifdef USE_RW_PIN 
output_low(LCD_RW); 
#endif 

output_low(LCD_E); 

// Some LCDs require 15 ms minimum delay after 
// power-up.  Others require 30 ms.  I'm going 
// to set it to 35 ms, so it should work with 
// all of them. 
delay_ms(35);          

for(i=0 ;i < 3; i++) 
   { 
    lcd_send_nibble(0x03); 
    delay_ms(5); 
   } 

lcd_send_nibble(0x02); 

for(i=0; i < sizeof(LCD_INIT_STRING); i++) 
   { 
    lcd_send_byte(0, LCD_INIT_STRING[i]); 
    
    // If the R/W signal is not used, then 
    // the busy bit can't be polled.  One of 
    // the init commands takes longer than 
    // the hard-coded delay of 50 us, so in 
    // that case, lets just do a 5 ms delay 
    // after all four of them. 
    #ifndef USE_RW_PIN 
    delay_ms(5); 
    #endif 
   } 

} 
void lcd_send_byte( BYTE address, BYTE n ) {

      lcd.rs = 0;
      while ( bit_test(lcd_read_byte(),7) ) ;
      lcd.rs = address;
      delay_cycles(1);
      lcd.rw = 0;
      delay_cycles(1);
      lcd.enable = 0;
      lcd_send_nibble(n >> 4);
      lcd_send_nibble(n & 0xf);
}
Beispiel #11
0
void lcd_send_byte(BYTE address, BYTE n)
{
   lcd_output_rs(0);
   while ( bit_test(lcd_read_byte(),7) ) ;
   lcd_output_rs(address);
   delay_cycles(1);
   lcd_output_rw(0);
   delay_cycles(1);
   lcd_output_enable(0);
   lcd_send_nibble(n >> 4);
   lcd_send_nibble(n & 0xf);
}
Beispiel #12
0
void lcd_init(void)
{
  CLOCK_BUSYWAIT_BIG_US(30000 + 10); //Wait 30ms after Vdd rises
  lcd_send_nibble(LCD_ALWAYS_mask | (LCD_FUNCTION_SET & 0xf0));
  LCD_COMMAND(LCD_FUNCTION_SET);
  CLOCK_BUSYWAIT_US(39+10);
  LCD_COMMAND(LCD_DISPLAY_ALL);
  CLOCK_BUSYWAIT_US(39+10);
  lcd_clear();
  LCD_COMMAND(LCD_ENTRY_MODE);
  CLOCK_BUSYWAIT_US(39+10);
  lcdinfo.pos = 0;
}
Beispiel #13
0
void lcd_init(void){
	int8 i;

	TRISRS=0;
	TRISEN=0;
#ifdef USE_RW
	TRISRW=0;
#endif

	RSPIN=0;
	EPIN=0;
#ifdef USE_RW
	RWPIN=0;
#endif

	TRIS_DATA_PIN_4=0;
	TRIS_DATA_PIN_5=0;
	TRIS_DATA_PIN_6=0;
	TRIS_DATA_PIN_7=0;

	_delay_5ms();//15ms
	_delay_5ms();
	_delay_5ms();

	for(i=0 ;i < 3; i++){
		lcd_send_nibble(0x03);
		_delay_5ms();//5ms
  	}

	lcd_send_nibble(0x02);

	for(i=0; i < sizeof(LCD_INIT_STRING); i++){
		lcd_send_byte(0, LCD_INIT_STRING[i]);
	#ifndef USE_RW
		_delay_5ms();
	#endif
	}
}
Beispiel #14
0
//---------------------------- 
void lcd_init(void) 
{ 
	char i; 
	
	output_low(LCD_RS); 
	
	#ifdef USE_LCD_RW 
	output_low(LCD_RW); 
	#endif 
	
	output_low(LCD_E); 
	
	delay_ms(15); 
	
	for(i=0 ;i < 3; i++) 
	{ 
		lcd_send_nibble(0x03); 
		delay_ms(5); 
	}
	
	lcd_send_nibble(0x02); 
	
	for(i=0; i < sizeof(LCD_INIT_STRING); i++) 
   { 
    lcd_send_byte(0, LCD_INIT_STRING[i]); 
    
    // If the R/W signal is not used, then 
    // the busy bit can't be polled.  One of 
    // the init commands takes longer than 
    // the hard-coded delay of 60 us, so in 
    // that case, lets just do a 5 ms delay 
    // after all four of them. 
    #ifndef USE_LCD_RW 
    delay_ms(5); 
    #endif 
   } 

} 
Beispiel #15
0
void lcd_init(void) 
{ 
   int8 i; 

   output_low(LCD_RS); 
   output_low(LCD_E); 

   delay_ms(15); 

   for(i=0 ;i < 3; i++) 
   { 
      lcd_send_nibble(0x03); 
      delay_ms(5); 
   } 

   lcd_send_nibble(0x02); 

   for(i=0; i < sizeof(LCD_INIT_STRING); i++) 
     { 
       lcd_send_byte(0, LCD_INIT_STRING[i]); 
       
       delay_ms(5); 
   } 
} 
Beispiel #16
0
void lcd_send_byte(int8 address, int8 n) 
{ 
   output_low(LCD_RS); 
   delay_us(60);  
    
   if(address) 
      output_high(LCD_RS); 
   else 
      output_low(LCD_RS); 
         
   delay_cycles(1); 
    
   output_low(LCD_E); 
    
   lcd_send_nibble(n >> 4); 
   lcd_send_nibble(n & 0xf); 
} 
Beispiel #17
0
uint8_t lcd_write(unsigned char chr, enum lcd_rs_t rs, uint8_t timeout) {
    unsigned char status;
    do {
        status = lcd_status();
    } while(lcd_is_busy(status) && timeout--);
    if(lcd_is_busy(status)) {
        lcd_info_set_write_timeout();
        return 0;
    }
    lcd_tris_set(0x00);
    lcd_en_pin = LCD_EN_LOW;
    lcd_rs_pin = rs;
    lcd_rw_pin = LCD_RW_WRITE;
    lcd_send_nibble(chr >> 4);
    lcd_send_nibble(chr);
    return 1;
}
void lcd_send_byte(int8 address, int8 n){

	RS_PIN=0;

	_delay_100us();


	TRIS_DATA_PIN_4=0;
	TRIS_DATA_PIN_5=0;
	TRIS_DATA_PIN_6=0;
	TRIS_DATA_PIN_7=0;

	if(address)
		RS_PIN=1;
	else
		RS_PIN=0;

	Nop();


	lcd_send_nibble(n >> 4);
	lcd_send_nibble(n & 0xf);
}
Beispiel #19
0
void lcd_init(){
  PIN_LCD_E  = 0;
  PIN_LCD_RS = 0;
  PIN_LCD_D4 = 0;
  PIN_LCD_D5 = 0;
  PIN_LCD_D6 = 0;
  PIN_LCD_D7 = 0;

  LCD_DELAY_LONG();

  lcd_send_nibble(3);
  Delay10KTCYx(6); //5ms

  lcd_send_nibble(3);
  Delay100TCYx(25); //200us

  lcd_send_nibble(3);
  Delay100TCYx(25); //200us

  lcd_send_nibble(2);
  Delay10KTCYx(6); //5ms

  lcd_send_nibble(2);
  lcd_send_nibble(8);      //4bits 2lines
  Delay10KTCYx(6); //5ms

  lcd_send_nibble(0);
  lcd_send_nibble(8);      //no shift, hide cursor
  Delay10KTCYx(6); //5ms

  lcd_send_nibble(0);
  lcd_send_nibble(1);      //clear
  Delay10KTCYx(6); //5ms

  lcd_send_nibble(0);
  lcd_send_nibble(6);      //left to right
  Delay10KTCYx(6); //5ms

  lcd_send_nibble(0);
  lcd_send_nibble(0xC);    //turn on
  Delay10KTCYx(6); //5ms

  LCD_DELAY_LONG();

}