Exemple #1
0
/*********************************************************************
 * Function: bool LCD_Initialize(void);
 *
 * Overview: Initializes the LCD screen.  Can take several hundred
 *           milliseconds.
 *
 * PreCondition: none
 *
 * Input: None
 *
 * Output: true if initialized, false otherwise
 *
 ********************************************************************/
bool LCD_Initialize ( void )
{
    LCD_DATA_LAT &= 0xFF00 ;
    LCD_DATA_TRIS &= 0xFF00 ;

    // Control signal data pins
    LCD_RWSignal_Clear ( ) ; // LCD R/W signal
    LCD_RSSignal_Clear ( ) ; // LCD RS signal
    LCD_EnableSignal_Clear ( ) ;     // LCD E signal

    // Control signal pin direction
    LCD_RSSignal_Output ( )  ;
    LCD_RWSignal_Output ( )  ;
    LCD_EnableSignal_Output ( ) ;

    LCD_EnableSignal_Set ( )  ;
    LCD_Wait ( LCD_STARTUP ) ;
    LCD_Wait ( LCD_STARTUP ) ;

    LCD_SendCommand ( LCD_COMMAND_SET_MODE_8_BIT ,     LCD_F_INSTR + LCD_STARTUP ) ;
    LCD_SendCommand ( LCD_COMMAND_CURSOR_OFF ,         LCD_F_INSTR ) ;
    LCD_SendCommand ( LCD_COMMAND_ENTER_DATA_MODE ,    LCD_S_INSTR ) ;

    LCD_ClearScreen ( ) ;

    return true ;
}
Exemple #2
0
/*********************************************************************
 * Function: static void LCD_SendCommand(char data)
 *
 * Overview: Sends command to LCD
 *
 * PreCondition: None
 *
 * Input: char - contains the command to be sent to the LCD
 *        unsigned int - has the specific delay for the command
 *
 * Output: None
 *
 ********************************************************************/
static void LCD_SendCommand ( char command , unsigned int delay )
{
    LCD_DATA_LAT &= 0xFF00 ;
    LCD_DATA_LAT |= command ;
    LCD_RWSignal_Clear ( ) ;
    LCD_RSSignal_Clear ( ) ;
    LCD_EnableSignal_Set ( ) ;
    Nop ( ) ;
    Nop ( ) ;
    Nop ( ) ;
    LCD_EnableSignal_Clear ( ) ;
    LCD_EnableSignal_Clear ( ) ;
    LCD_Wait ( delay ) ;
}
Exemple #3
0
/*********************************************************************
 * Function: static void LCD_SendData(char data)
 *
 * Overview: Sends data to LCD
 *
 * PreCondition: None
 *
 * Input: char - contains the data to be sent to the LCD
 *
 * Output: None
 *
 ********************************************************************/
static void LCD_SendData ( char data )
{
    LCD_RWSignal_Clear ( ) ;
    LCD_RSSignal_Set ( ) ;
    LCD_DATA_LAT &= 0xFF00 ;
    LCD_DATA_LAT |= data ;
    LCD_EnableSignal_Set ( ) ;
    Nop ( ) ;
    Nop ( ) ;
    Nop ( ) ;
    LCD_EnableSignal_Clear ( ) ;
    LCD_RSSignal_Clear ( ) ;
    LCD_Wait ( LCD_F_INSTR ) ;
}
Exemple #4
0
/*********************************************************************
* Function: bool LCD_Initialize(void);
*
* Overview: Initializes the LCD screen.  Can take several hundred
*           milliseconds.
*
* PreCondition: none
*
* Input: None
*
* Output: true if initialized, false otherwise
*
********************************************************************/
bool LCD_Initialize(void)
{
    LATC |= 0x00FF;
    TRISC &= 0x0F00;
    TRISB &= 0xFC7F;

    // Control signal data pins
    LATBbits.LATB8 = 0; // LCD R/W signal
    LATBbits.LATB9 = 0; // LCD RS signal
    LATBbits.LATB7  = 0;     // LCD E signal

    // Control signal pin direction
      TRISBbits.TRISB8 = 0;
    TRISBbits.TRISB9 = 0;
    TRISBbits.TRISB7 = 0;



    LATC |= 0x0038;

    LATBbits.LATB7  = 1;
    Nop();
    Nop();
    Nop();
    LATBbits.LATB7  = 0;

    LCD_Wait(LCD_STARTUP);
    LCD_Wait(LCD_STARTUP);

    LCD_SendCommand(LCD_COMMAND_SET_MODE_8_BIT,     LCD_F_INSTR + LCD_STARTUP);
    LCD_SendCommand(LCD_COMMAND_CURSOR_ON,         LCD_F_INSTR);
    LCD_SendCommand(LCD_COMMAND_ENTER_DATA_MODE,    LCD_S_INSTR);

    LCD_ClearScreen();

	return true;
}
//функция записи данных
void LCD_WriteData(unsigned char data)
{
  LCD_Wait();
  SetBit(PORT_SIG_RS, RS);	        //установка RS в 1 - данные
  LCD_CommonFunc(data);
}
//функция записи команды 
void LCD_WriteCom(unsigned char data)
{
  LCD_Wait();
  ClearBit(PORT_SIG_RS, RS);	//установка RS в 0 - команды
  LCD_CommonFunc(data);
}