Example #1
0
void LCDinit(void) {
  delay_ms(40);
  LCDnibble(system_set_4_bit >> 4);
  delay_ms(5);
  LCDnibble(system_set_4_bit >> 4);
  delay_ms(5);
  LCDnibble(system_set_4_bit >> 4);
  delay_ms(5);

  // Reset complete. Start init

  LCDchar(system_set_4_bit);
  delay_ms(2);
  LCDchar(display_off);
  delay_ms(2);
  LCDchar(entry_mode);
  delay_ms(2);
  LCDchar(display_on);
  delay_ms(2);
  LCDchar(set_dd_ram);
  delay_ms(2);

  // Data mode
  PORTB |= RS;
}
Example #2
0
void LCDprint(char *characters)
{
  while (*characters)
  {
    LCDchar(*characters++);
  }
}
Example #3
0
//Initialise the LCD display, and set it to initially display
//all segments.
void LCDinit(void)
{
    int i;

    for (i = 0;  i < 21;  i++)
        LCDMEM[i] = 0;
#if defined(__MSP430_HAS_LCD4__)
#if defined(__MSP430_E423__) || defined(__MSP430_E425__) || defined(__MSP430_E427__)
    LCDCTL = (LCDSG0_3 | LCD4MUX | LCDON);
#else
    LCDCTL = (LCDSG0_5 | LCD4MUX | LCDON);
#endif
#endif
#if defined(__MSP430_HAS_LCD_A__)
    /* LCD-A controller setup */
    LCDACTL = LCDFREQ_128 | LCD4MUX | LCDSON | LCDON;
    LCDAPCTL0 = LCDS0 | LCDS4 | LCDS8 | LCDS12 | LCDS16 | LCDS20 | LCDS24 | LCDS28;
    LCDAPCTL1 = LCDS32 | LCDS36;
    LCDAVCTL0 = LCDCPEN;
    LCDAVCTL1 = 1 << 1;
#endif
    for (i = 1;  i <= lcd_cells;  i++)
        LCDchar(0xFFFF, i);
#if defined(__MSP430_HAS_LCD4__)
#if defined(__MSP430_412__) || defined(__MSP430_413__) || defined(__MSP430_435__) || defined(__MSP430_436__) || defined(__MSP430_437__) || defined(__MSP430_447__) || defined(__MSP430_448__) || defined(__MSP430_449__)
    P5SEL |= (BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7);
#endif
#endif
#if defined(__MSP430_HAS_LCD_A__)
#if defined(__MSP430_G4618__) || defined(__MSP430_G4619__)
    P5SEL |= (BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7);
#else
    P5SEL |= (BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7);
#endif
#endif
}
Example #4
0
void main(void) {
  char ch;
  
  asm {
    clrf	PORTA
    clrf	PORTB
    bsf         STATUS,RP0
    movlw	0x0C
    movwf	TRISA
    clrf	TRISB
    bcf	        STATUS,RP0
  }

  // Init both LCDs at the same time
  emask = E1 | E2;
  LCDinit();
  
  // Say hi until the serial port says otherwise
  emask = E1;
  LCDstring("LCD interface ready");
  emask = E2;
  LCDstring("Micah Dowty, July 2000");
  emask = E1;

  // Wait for input
  while (1) {
    ch = getchar();

    // Process escape chars
    if (ch == '\\') {
      ch = getchar();
      switch (ch) {

      case '\\':
	LCDchar('\\');
	break;

      case '1':    // First display
	emask = E1;
	break;

      case '2':    // Second display
	emask = E2;
	break;

      case '*':    // All displays
	emask = E1 | E2;
	break;

      case 'c':    // Next char is an LCD command
	ch = getchar();
	LCDcmd(ch);
	break;

      case 's':    // Clear screen
	LCDcmd(clear_lcd);
	break;

      case 'g':    // Go to the beginning of CGRAM
	LCDcmd(set_cg_ram);
	break;

      case 'd':    // Go to the beginning of DDRAM
	LCDcmd(set_dd_ram);
	break;

      case 'b':    // Beep
	output_high_port_a(BEEPER);
	delay_ms(250);
	output_low_port_a(BEEPER);
	break;

      case 'f':    // Flash
	output_high_port_a(LED);
	delay_ms(250);
	output_low_port_a(LED);
	break;

      case 'n':    // Go to line 2
	LCDcmd(set_dd_ram + 40);
	break;

      }
    }
    else {
      LCDchar(ch);
    }
  }
}