Exemple #1
0
void lcd_init( void )
{
  LCD_DDR_D4 = 1;                               // enable output pins
  LCD_DDR_D5 = 1;
  LCD_DDR_D6 = 1;
  LCD_DDR_D7 = 1;
  LCD_DDR_RS = 1;
  LCD_DDR_E0 = 1;
  LCD_E0 = 0;
  LCD_RS = 0;                                   // send commands

  _delay_ms( 15 );
  lcd_nibble( 0x30 );
  _delay_ms( 4.1 );
  lcd_nibble( 0x30 );
  _delay_us( 100 );
  lcd_nibble( 0x30 );
  _delay_us( LCD_TIME_DAT );
  lcd_nibble( 0x20 );                           // 4 bit mode
  _delay_us( LCD_TIME_DAT );
#if LCD_LINE == 1
  lcd_command( 0x20 );                          // 1 line
#else
  lcd_command( 0x28 );                          // 2 lines 5*7
#endif
  lcd_command( 0x08 );                          // display off
  lcd_command( 0x01 );                          // display clear
  lcd_command( 0x06 );                          // cursor increment
  lcd_command( 0x0C );                          // on, no cursor, no blink
}
Exemple #2
0
void lcd_send_instr(unsigned char data) {

	lcd_e(0);
    
    lcd_rs(0);	// wysy³amy instrukcjê

	// starszy nibble 0xF-
	lcd_e(1);

	lcd_nibble( data >> 4 );

	lcd_e(0);
	_delay_us(50);_delay_us(50);

	// m³odszy nibble 0x-F
	lcd_e(1);

	lcd_nibble( data & 0x0f);

	lcd_e(0);
	_delay_us(50);_delay_us(50);

}
Exemple #3
0
void lcd_send_data(unsigned char data) {

    lcd_e(0);

	lcd_rs(1);

	// starszy nibble 0xF-
	lcd_e(1);

	lcd_nibble( data >> 4 );

	lcd_e(0);
	_delay_us(50);_delay_us(50);

	// m³odszy nibble 0x-F
	lcd_e(1);

	lcd_nibble( data & 0x0f);

	lcd_e(0);
	_delay_us(50);_delay_us(50);

}
Exemple #4
0
static void lcd_byte( uint8_t d )
{
  lcd_nibble( d );
  lcd_nibble( d<<4 );
  _delay_us( LCD_TIME_DAT );
}
Exemple #5
0
void lcd_setup()
{
   unsigned idata i=0;

   LCD_E   = 0;
   LCD_R_W = 0;
   LCD_RS  = 0;

#if defined(CPU_C8051F120)
   SFRPAGE = CONFIG_PAGE;
   P2MDOUT = 0xFF;             // all push-pull
#if defined(SCS_2000) || defined(SCS_2001)
   P1MDOUT |= 0x03;
   LCD_1D = 1;                 // a to b for data
   LCD_2D = 1;                 // a to b for control
#endif
#else
   PRT2CF = 0xFF;              // all push-pull
#endif

#if defined(SCS_900) || defined(SCS_1001) || defined(SCS_2000)  || defined(SCS_2001)
// 4-line LCD display with KS0078 controller

   LCD &= ~(0xFE);
   LCD |= 0x20;  // set 4-bit interface
   LCD_E = 1;
   delay_us(1);
   LCD_E = 0;
   delay_ms(1);
   lcd_nibble(0x20); // function set: 4-bit, RE=0

   // test if LCD present

   LCD = LCD | 0xF0;            // data input
#if defined(CPU_C8051F120)
   SFRPAGE = CONFIG_PAGE;
#if defined(SCS_2000) || defined(SCS_2001)
   P2MDOUT |= 0x0F;
   LCD_1D = 0;                  // b to a for data
#else
   P2MDOUT = 0x0F;
#endif
#else
   PRT2CF = 0x0F;
#endif
   LCD_RS = 0;                  // select BF
   LCD_R_W = 1;
   delay_us(1);
   LCD_E = 1;
   delay_us(100);               // let signal settle
   if (LCD_DB7) {
      lcd_present = 0;
      return;
   }

   lcd_present = 1;

   lcd_out(0x24, 0); // function set: 4-bit, RE=1
   lcd_out(0x0B, 0); // ext function set: 4-line display, inverting cursor
   lcd_out(0x20, 0); // function set: 4-bit, RE=0
   lcd_out(0x0C, 0); // display on
   lcd_out(0x01, 0); // clear display
   lcd_out(0x06, 0); // entry mode: incrementing

#else // 2-line LCD display with KS0066 controller

   LCD &= ~(0xFE);
   delay_ms(15);
   LCD |= 0x30;

   LCD_E = 1;
   delay_us(1);
   LCD_E = 0;
   delay_ms(5);

   LCD_E = 1;
   delay_us(1);
   LCD_E = 0;
   delay_ms(1);

   LCD_E = 1;
   delay_us(1);
   LCD_E = 0;

   LCD = 0x20;                  // set 4-bit interface
   LCD_E = 1;
   delay_us(1);
   LCD_E = 0;

   // test if LCD present

   LCD = LCD | 0xF0;            // data input
#if defined(CPU_C8051F120)
   SFRPAGE = CONFIG_PAGE;
   P2MDOUT = 0x0F;
#else
   PRT2CF = 0x0F;
#endif
   LCD_RS = 0;                  // select BF
   LCD_R_W = 1;
   delay_us(1);
   LCD_E = 1;
   delay_us(100);               // let signal settle
   if (LCD_DB7) {
      lcd_present = 0;
      return;
   }

   lcd_present = 1;

   lcd_out(0x2C, 0);            // select 2 lines, big font
   lcd_out(0x0C, 0);            // display on
   lcd_out(0x01, 0);            // clear display
   lcd_out(0x06, 0);            // entry mode
#endif
}