Esempio n. 1
0
/* 
 * The writeLCD() function uses the writeFourBits() function to send an 8 bit command/data to the
 * LCD.
 */
void writeLCD(unsigned char word, unsigned int commandType, unsigned int delayAfter){
    //TODO:
    char first = (word&0xF0)>>4;    //USED E INSTEAD OF F
    char second = word&0x0F;
    writeFourBits(first, commandType, 0, 0);
    writeFourBits(second, commandType, delayAfter, 1);
}
Esempio n. 2
0
/*Initialize the LCD
 */
void initLCD(void) {
    //Set all the pins as OUTPUTs and initialize them to 0
    TRISEbits.TRISE1 = OUTPUT;  //Tristate buffer associated with LCD_D7
    TRISEbits.TRISE3 = OUTPUT;  //Tristate buffer associated with LCD_D6
    TRISEbits.TRISE5 = OUTPUT;  //Etc...
    TRISEbits.TRISE7 = OUTPUT; 
    LCD_D7= 0;    LCD_D6 = 0;    LCD_D5 = 0;    LCD_D4 = 0;
    //Data pins above, function bits below.
    TRISBbits.TRISB2 = OUTPUT; TRISBbits.TRISB4 = OUTPUT;
    LCD_E = 0; LCD_RS = 0;
    
    delayUs(15000); //delay 15 ms as per LCD datasheet
    
    writeFourBits(0b0011, COMMAND, 4100, LOWER); //write 0011 as per datasheet and wait 4.1 ms
    writeFourBits(0b0011, COMMAND, 100, LOWER);
    
          //Word, Command, DelayAfter
    writeLCD(0x32, COMMAND, 40);    //4 bit function set
    writeLCD(0x28, COMMAND, 40);    //function set
    writeLCD(0x08, COMMAND, 40);    //display off
    writeLCD(0x01, COMMAND, 1640);  //display clear
    writeLCD(0x06, COMMAND, 40);    //entry mode set
    
    writeLCD(0b1101, COMMAND, 40);
}
Esempio n. 3
0
/*
 * The myTestLCD() function was originally created for preliminary testing *DEPRECATED*
 */
void myTestLCD() {
    char test = 0b01100110;
    initLCD();
    
    /*
    LATCbits.LAT_RS = DATA;
    LATEbits.LAT_D7 = ((test>>4)&0b1000) >> 3;
    LATEbits.LAT_D6 = (test>>4)&0b0100;
    LATEbits.LAT_D5 = (test>>4)&0b0010;
    LATEbits.LAT_D4 = (test>>4)&0b0001;
    
    toggleE();
    
    LATCbits.LAT_RS = DATA;
    LATEbits.LAT_D7 = DISABLED;
    LATEbits.LAT_D6 = ENABLED;
    LATEbits.LAT_D5 = ENABLED;
    LATEbits.LAT_D4 = DISABLED;
    
    toggleE();
     * */
    writeFourBits(0b0110, DATA, 500, 1);
    writeFourBits(0b0110, DATA, 500, 1);
   // moveCursorLCD(0, 4);
   //printCharLCD('S');
}
Esempio n. 4
0
/*Initialize the LCD
 */
void initLCD(void) {
    // Setup D, RS, and E to be outputs (0).
    TRIS_D7 = 0;
    TRIS_D6 = 0;
    TRIS_D5 = 0;
    TRIS_D4 = 0;
    TRIS_RS = 0;
    TRIS_E = 0;

    // Initilization sequence utilizes specific LCD commands before the general configuration
    // commands can be utilized. The first few initilition commands cannot be done using the
    // WriteLCD function. Additionally, the specific sequence and timing is very important.

    // Enable 4-bit interface
    writeFourBits(0b0011, 0, 5, LOWER);

    // Function Set (specifies data width, lines, and font.
    writeFourBits(0b0011, 0, 1, LOWER);

    // 4-bit mode initialization is complete. We can now configure the various LCD
    // options to control how the LCD will function.

    writeFourBits(0b0011, 0, 1, LOWER);   //before function set 4bit
    writeFourBits(0b0010, 0, 1, LOWER);     //after function set 4bit

    writeLCD(0b00101000,0,0);   //function set, n is 1, f is 0
    writeLCD(0b00001000,0,0);   //display off
    writeLCD(0b00000001,0,0);   //display clear
    writeLCD(0b00000110,0,0);   //entry mode set, i/d =1, s=0

    writeLCD(0b00001111,0,0);   //display on, cursor blink

    // TODO: Display On/Off Control
        // Turn Display (D) Off
    // TODO: Clear Display (The delay is not specified in the data sheet at this point. You really need to have the clear display delay here.
    // TODO: Entry Mode Set
        // Set Increment Display, No Shift (i.e. cursor move)
    // TODO: Display On/Off Control
        // Turn Display (D) On, Cursor (C) Off, and Blink(B) Off
}
Esempio n. 5
0
File: LCD.c Progetto: pdxfrog/ECE372
void initLCD(void){
    TRISE = 0x00; // Set first six bits in TRISE to 0
    
    // Wait to make absolutely certain power is on.
    delay(7500);
    delay(7500);
    // Gave delays 10% margin
    writeFourBits(0x03, COMMAND, 4510, LOWER);
    
    writeFourBits(0x03, COMMAND, 110, LOWER);
    
    writeFourBits(0x03, COMMAND, 40, LOWER);
    
    writeFourBits(0x02, COMMAND, 40, LOWER);
    
    writeFourBits(0x28, COMMAND, 10, UPPER);
    writeFourBits(0x28, COMMAND, 50, LOWER);
    
    writeFourBits(0x08, COMMAND, 10, UPPER);
    writeFourBits(0x08, COMMAND, 50, LOWER);
    
    writeFourBits(0x01, COMMAND, 10, UPPER);
    writeFourBits(0x01, COMMAND, 1804, LOWER);
    
    writeFourBits(0x06, COMMAND, 10, UPPER);
    writeFourBits(0x06, COMMAND, 50, LOWER);
    
    writeFourBits(0x0F, COMMAND, 50, UPPER);
    writeFourBits(0x0F, COMMAND, 50, LOWER);
}
Esempio n. 6
0
File: LCD.c Progetto: pdxfrog/ECE372
void writeLCD(unsigned char word, unsigned int commandType, unsigned short int delay){
    writeFourBits(word, commandType, delay, UPPER);
    writeFourBits(word, commandType, delay, LOWER);
}
Esempio n. 7
0
/* Using writeFourBits, this function should write the two bytes of a character
 * to the LCD.
 */
void writeLCD(unsigned char word, unsigned int commandType, unsigned int delayAfter){
    writeFourBits(word, commandType, delayAfter, UPPER);
    writeFourBits(word, commandType, delayAfter, LOWER);
}
Esempio n. 8
0
/* Using writeFourBits, this function should write the two bytes of a character
 * to the LCD.
 */
void writeLCD(unsigned char word, unsigned int commandType, unsigned int delayAfter){
    //TODO:
    writeFourBits(word, commandType, delayAfter, UPPER); // Writes upper 4 bits of work into LCD mem
    writeFourBits(word, commandType, delayAfter, LOWER); // Writes lower 4 bits of work into LCD mem
}
Esempio n. 9
0
File: lcd.c Progetto: rtfi/final
/*Initialize the LCD
 */
void initLCD(void) {
    // Setup D, RS, and E to be outputs (0).
    TRIS_D7 = 0;
    TRIS_D6 = 0;
    TRIS_D5 = 0;
    TRIS_D4 = 0;
    TRIS_RS = 0;
    TRIS_E = 0;
    // Initilization sequence utilizes specific LCD commands before the general configuration
    // commands can be utilized. The first few initilition commands cannot be done using the
    // WriteLCD function. Additionally, the specific sequence and timing is very important.

    //Wait 15ms after LCD turned on
    delayUs(15000);
    //=========================================================
    writeFourBits(0x03, SEND_COMMAND, 4100, LOWER);//0011
    //=========================================================
    writeFourBits(0x03, SEND_COMMAND, 100, LOWER);//0011
    //=========================================================
    writeFourBits(0x03, SEND_COMMAND, 40, LOWER);//0011
    //=========================================================
    writeFourBits(0x02, SEND_COMMAND, 40, LOWER);//0010
    //=========================================================
    writeFourBits(0x02, SEND_COMMAND, 40, LOWER);//0010

    writeFourBits(0x08, SEND_COMMAND, 40, LOWER);//1010
    //=========================================================
    writeFourBits(0x00, SEND_COMMAND, 40, LOWER);//0000

    writeFourBits(0x08, SEND_COMMAND, 40, LOWER);//1000 0x08
    //=========================================================
    writeFourBits(0x00, SEND_COMMAND, 40, LOWER);//0000

    writeFourBits(0x01, SEND_COMMAND, 1640, LOWER);//0001
    //=========================================================
    writeFourBits(0x00, SEND_COMMAND, 40, LOWER);//0000

    writeFourBits(0x06, SEND_COMMAND, 40, LOWER);//0110
    //=========================================================
    writeFourBits(0x01, SEND_COMMAND, 40, UPPER);

    writeFourBits(0x01, SEND_COMMAND, 1640, LOWER);
    //=========================================================
    writeFourBits(0x0C, SEND_COMMAND, 40, UPPER);

    writeFourBits(0x0C, SEND_COMMAND, 40, LOWER);


    //
    //DONE



}
Esempio n. 10
0
File: lcd.c Progetto: rtfi/final
/* Using writeFourBits, this function should write the two bytes of a character
 * to the LCD.
 */
void writeLCD(unsigned char word, unsigned int commandType, unsigned int delayAfter){
    writeFourBits(word, commandType, delayAfter, UPPER); // write upper 4 bits
    writeFourBits(word, commandType, delayAfter, LOWER); // write lower 4 bits
}
Esempio n. 11
0
File: lcd.c Progetto: rtfi/final
void clearCursor(){
    writeFourBits(0x0E, SEND_COMMAND, 40, UPPER);
    writeFourBits(0x0E, SEND_COMMAND, 40, LOWER);
}
Esempio n. 12
0
File: lcd.c Progetto: rtfi/final
/*
 * Clear the display.
 */
void clearLCD(){
    writeFourBits(0x01, SEND_COMMAND, 40, UPPER);
    writeFourBits(0x01, SEND_COMMAND, 1640, LOWER);
}