Exemplo n.º 1
0
/*
  writedata - Output a byte to the LCD display data register
*/
void writedata(unsigned char x)
{
  PORTB |= (1<<PB0);//sets RS as 1 for data
  writenibble(x);
  writenibble(x<<4);
  _delay_ms(2);
}
Exemplo n.º 2
0
void init_lcd()
{
    DDRD &= ~((1<<PD4)|(1<<PD5)|(1<<PD6)|(1<<PD7));//clear register D
    DDRD |= ((1<<PD4)|(1<<PD5)|(1<<PD6)|(1<<PD7));//sets D4-D7 as output; used for sending bits
    DDRB &= ~((1<<PB0)|(1<<PB1));//clear register B
    DDRB |= ((1<<PB0)|(1<<PB1));//sets D8 & D9 as output; PB0/D8 used for Register Select(RS), PB1/D9 used for Enable
    _delay_ms(15);
    PORTB &= ~(1<<PB0);              // Delay at least 15ms
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_ms(5);               // Delay at least 4msec
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_us(100);             // Delay at least 100usec
    writenibble(0b00110000);
    // Use writenibble to send 0011, no delay needed
    writenibble(0b00100000);
    // Use writenibble to send 0010    // Function Set: 4-bit interface
    _delay_ms(2);
    
    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines

    writecommand(0x0f);         // Display and cursor on
    _delay_ms(2);

}
Exemplo n.º 3
0
Arquivo: lcd.c Projeto: NikTRSK/EE109
/*
  init_lcd - Do various things to initialize the LCD display
*/
void init_lcd()
{
    DDRD |= (1 << PD7) | (1 << PD6) | (1 << PD5) | (1 << PD4);  // initialize data lines
    DDRB |= (1 << PB1) | (1 << PB0);                            // initialize Reg select & Enable

    _delay_ms(15);              // Delay at least 15ms

    // Use writenibble to send 0011
    writenibble(0x30);
    _delay_ms(5);               // Delay at least 4msec

    // Use writenibble to send 0011
    writenibble(0x30);
    _delay_us(120);             // Delay at least 100usec

    // Use writenibble to send 0011, no delay needed
    writenibble(0x30);

    // Use writenibble to send 0010    // Function Set: 4-bit interface
    writenibble(0x20);
    _delay_ms(2);

    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines
    _delay_ms(2);

    writecommand(0x0F);         // Display and cursor on
    _delay_ms(2);

}
Exemplo n.º 4
0
/*
  writecommand - Output a byte to the LCD display instruction register.
*/
void writecommand(unsigned char x)
{
  PORTB &= ~(1<<PB0);//sets RS as 0 for command
  writenibble(x);
  writenibble(x<<4);
  _delay_ms(2);
}
Exemplo n.º 5
0
/*
  writedata - Output a byte to the LCD display data register
*/
void writedata(unsigned char x)
{
    PORTB |= (1 << PB0);//set register select to 1 (data register)
    writenibble(x);//send 4 msb in first (lsb cleared to 0 in writenibble)
    writenibble(x << 4);//shift left logical by 4 to send in lsb
    _delay_ms(2);
}
Exemplo n.º 6
0
Arquivo: lcd.c Projeto: NikTRSK/EE109
/*
  writecommand - Output a byte to the LCD display instruction register.
*/
void writecommand(unsigned char x)
{
  PORTB &= ~(1 << PB0); // set RS = 0, for the command register
  writenibble(x);       // read the upper 4 bits
  writenibble(x << 4);       // read lower 4 bits

  _delay_ms(2);
}
Exemplo n.º 7
0
Arquivo: lcd.c Projeto: NikTRSK/EE109
/*
  writedata - Output a byte to the LCD display data register
*/
void writedata(unsigned char x)
{
  PORTB |= (1 << PB0);  // set RS = 1, for the data register
  writenibble(x);       // read the upper 4 bits
  x = (x << 4);         // shift lower 4 bits
  writenibble(x);       // read lower 4 bits

  _delay_ms(2);
}
Exemplo n.º 8
0
/*
  writebyte - Output a byte to the LCD display instruction register.
*/
void writebyte(unsigned char x, unsigned char rs) {
  if(rs == 0x00) {
    PORTB &= ~(0x01);
  } else {
    PORTB |= 0x01;
  }

  // Set upper and lower bits
  unsigned char upper = ((x & 0xF0) >> 4);
  unsigned char lower = (x & 0x0F);

  // Write upper bits
  writenibble(upper);
  // Write lower bits
  writenibble(lower);

  // Delay to finish
  _delay_ms(2);
}
Exemplo n.º 9
0
/*
  init_lcd - Do various things to initialize the LCD display
*/
void init_lcd()
{
    DDRD |= (1 << PD7);//configure port as output
    DDRD |= (1 << PD6);
    DDRD |= (1 << PD5);
    DDRD |= (1 << PD4);
    DDRB |= (1 << PB0);
    DDRB |= (1 << PB1);
    _delay_ms(15);              // Delay at least 15ms
    writenibble(0x30); // Use writenibble to 78send 0011
    _delay_ms(5);               // Delay at least 4msec
    writenibble(0x30); // Use writenibble to send 0011
    _delay_us(120);             // Delay at least 100usec
    writenibble(0x30); // Use writenibble to send 0011, no delay needed
    writenibble(0x20); // Use writenibble to send 0010  // Function Set: 4-bit interface
    _delay_ms(2);
    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines
    _delay_ms(2);
    writecommand(0xf0);         // Display and cursor on
    _delay_ms(2);
}
Exemplo n.º 10
0
Arquivo: lcd.c Projeto: monolli/ee109
/*
  init_lcd - Do various things to initialize the LCD display
*/
void init_lcd()
{
    _delay_ms(15);              // Delay at least 15ms
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_ms(5);               // Delay at least 4msec
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_us(120);             // Delay at least 100usec
    writenibble(0b00110000);
    // Use writenibble to send 0011, no delay needed
    writenibble(0b00100000);
    // Use writenibble to send 0010    // Function Set: 4-bit interface
    _delay_ms(2);

    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines

    writecommand(0x0f);         // Display and cursor on

    writecommand(1);

}
Exemplo n.º 11
0
/*
  init_lcd - Do various things to initialize the LCD display.
*/
void init_lcd() {
  _delay_ms(15);              // Delay at least 15ms

  writenibble(0x03);          // Use writenibble to send 0011
  _delay_ms(5);               // Delay at least 4msec

  writenibble(0x03);          // Use writenibble to send 0011
  _delay_us(120);             // Delay at least 100usec

  writenibble(0x03);          // Use writenibble to send 0011
  
  writenibble(0x02);          // Use writenibble to send 0010
  _delay_ms(2);
  
  writebyte(0x28, 0x00);      // Function Set: 4-bit interface, 2 lines
  _delay_ms(2);

  writebyte(0x0F, 0x00);      // Display and cursor on
  _delay_ms(2);

  clear();                    // Clear everything
  PORTB |= 0x04;              // Enable backlight
}