void main(void) { // rst=0; nop(); nop(); nop(); // rst=1; textsize=graphicsize=size_lie/8*size_hang;// textsize_l=textsize;// textsize_h=textsize>>8;// graphicsize_h=graphicsize>>8; graphicsize_l=graphicsize; text_startaddr=0x0000; text_startaddr_h=text_startaddr>>8;// text_startaddr_l=text_startaddr; graphic_startaddr=text_startaddr+textsize;// graphic_startaddr_h=graphic_startaddr>>8;// graphic_startaddr_l=graphic_startaddr; double_byte_parameter(text_startaddr_l,text_startaddr_h,0x40);//TEXT double_byte_parameter((size_lie/8),0x00,0x41); double_byte_parameter(graphic_startaddr_l,graphic_startaddr_h,0x42); double_byte_parameter((size_lie/8),0x00,0x43); no_parameter(0x80);//TEXT OR GRAPHIC no_parameter(0xa3);// CGRAM(); while(1) { all_display(1,0x00); no_parameter(0x98);//TEXT OFF ,GRAPHIC ON display_map(&sch); delay1s(); display_8HO(&graphich8o); delay1s(); no_parameter(0x94); //TEXT ON,GRAPHIC OFF all_display(0,0x00); displayHZ(); delay1s(); all_display(0,0x00); display8hotext(); delay1s(); } }
void InitDisplay() { unsigned int config1 = I2C_ON | I2C_7BIT_ADD; //unsigned int config2 = 15; // Works with no pll in use unsigned int config2 = 24; delay(100); // THIS IS REQUIRED TO ALLOW THE VOLTAGE TO STABILIZE BEFORE INIT-ING THE DISPLAY ConfigIntI2C1(MI2C_INT_OFF); //Disable I2C interrupt CloseI2C1(); OpenI2C1( config1, config2); IdleI2C1(); // Assert a start condition StartI2C1(); while(_SEN); // Write the address of the slave MasterWriteI2C1(Slave); while(I2C1STATbits.TBF); //Wait till address is transmitted while(!IFS1bits.MI2C1IF); //Wait for ninth clock cycle MasterWriteI2C1(Comsend); IdleI2C1(); MasterWriteI2C1(0x38); IdleI2C1(); delay(10); MasterWriteI2C1(0x39); IdleI2C1(); delay(10); MasterWriteI2C1(0x14); IdleI2C1(); MasterWriteI2C1(0x25); IdleI2C1(); MasterWriteI2C1(0x5E); IdleI2C1(); MasterWriteI2C1(0x6D); IdleI2C1(); MasterWriteI2C1(0x0C); IdleI2C1(); MasterWriteI2C1(0x01); IdleI2C1(); MasterWriteI2C1(0x06); IdleI2C1(); delay(10); StopI2C1(); IdleI2C1(); CGRAM(); //define CGRAM StartI2C1(); MasterWriteI2C1(Slave); IdleI2C1(); MasterWriteI2C1(Comsend); IdleI2C1(); MasterWriteI2C1(0x39); IdleI2C1(); MasterWriteI2C1(0x01); //go back Home IdleI2C1(); StopI2C1(); delay(10); }