Esempio n. 1
0
File: lcd.c Progetto: gen1izh/c
void init_lcd() {
    // PMP initialization
    PMCON   = 0x83bf; // enable PMP with long waits
    PMMODE  = 0x3ff;  // master mode 1
    PMAEN   = 0x0001; // PMA0 enable
    // init timer 1
    T1CON   = 0x8030; // Fosc/2, 1:256, 16us/tick
    lcdWait (2000); // wait for > 30ms
    // setup for 8 bit mode
    PMADDR  = LCDCMD;
    PMDATA  = 0x1000; // 0x0011000; TODO: warning large integer implicitly truncated to unsigned type
    // Wait for > 40us so the LCD can do its thing
    TMR1    = 0;
    lcdWait (3);
    PMDATA  = 0b00001100;   // ON, cursor off, blink off
    lcdWait (3);
    PMDATA  = 00000001;      // clear display
    lcdWait (100);
    PMDATA  = 0b00000110;    // increment cursor, no shift
    lcdWait(100);
}
Esempio n. 2
0
void lcdWrite(unsigned char dat,bool cmd,bool tstbusy) //0:cmd 1:not cmd
{
	if(tstbusy) lcdWait();
	CON_PORT&=~( (1<<RS) | (1<<RW) | (1<<EN) );
	DAT_DDR|=0x0f;
	DAT_PORT&=~0x0f;
	CON_PORT|=(cmd<<RS);
	//CON_PORT&=~(1<<RW);
	DAT_PORT|=((dat&0xf0) >> 4);
	CON_PORT|=(1<<EN);
	CON_PORT&=~(1<<EN);
	DAT_PORT&=~0x0f;
	DAT_PORT|= dat & 0x0f;
	CON_PORT|=(1<<EN);
	CON_PORT&=~(1<<EN);
	DAT_PORT&=~0x0f;
}