/* I2C LCD Operation [½ÄÛÍÞØ°¥Øů¸½] PIC12F629 4MHz Last M 11/27 Start 2010/11/24 by M.Kikuchi Config=0x31C4 */ sbit Soft_I2C_Scl at GP4_bit; sbit Soft_I2C_Sda at GP5_bit; sbit Soft_I2C_Scl_Direction at TRISIO4_bit; sbit Soft_I2C_Sda_Direction at TRISIO5_bit; char Contrast= 0b101100; //3.2V+- // Contrast = 0b111000; //2.6V+- = 0b100000; //3.8V+- extern void Lcd_Comd(); extern void Lcd_Data(); extern void Lcd_I2c_Set(); extern void Lcd_Pos(const char *S); extern void Lcd_Icon_Dsp(char I_add,char I_bit); void Lcd_Comd(char X1) { Soft_I2C_Start(); Soft_I2C_Write(0x7c); //I2C address Soft_I2C_Write(0x0); // Soft_I2C_Write(X1); // Soft_I2C_Stop(); Delay_us(30); } void Lcd_Data(char X1) { Soft_I2C_Start(); Soft_I2C_Write(0x7c); //I2C address Soft_I2C_Write(0x40); // Soft_I2C_Write(X1); // Soft_I2C_Stop(); Delay_us(30); } void Lcd_I2c_Set() { Delay_ms(40); Lcd_Comd(0x38); //Function Lcd_Comd(0x39); //Function Lcd_Comd(0x14); //internal OSC Lcd_Comd(0x40); //set Icon address Lcd_Comd(0x10); //Icon bit Lcd_Comd(0x70 | (Contrast & 0x0F)); //Contrast set Lcd_Comd(0x5C | ((Contrast >>4)& 3)); Lcd_Comd(0x6C); //FolloworControl Delay_ms(300); // Lcd_Comd(0x38); //Function again Lcd_Comd(0x08); Lcd_Comd(0x0C); //Display on Lcd_Comd(0x06); //Entry mode increment Lcd_Comd(0x01); //Clear Display Delay_ms(2); } void Lcd_Pos(const char *S) { while (*S) Lcd_Data(*S++); } void Lcd_Icon_Dsp(char I_add,char I_bit) { // I_add=Icon Address I_bit=Icon bit Lcd_Comd(0x39); //Function Specal Lcd_Comd(0x40 | I_add); //set of Icon Address Lcd_Data(I_bit); //set of Icon bit Lcd_Comd(0x38); } void main() { char i; TRISIO=0b00001001; GPIO=0; Soft_I2C_Init(); // set of I2C Lcd_I2c_Set(); // set of begin LCD Lcd_Icon_Dsp(0x0d,0x1e); // “d’r Box Lcd_Icon_Dsp(0,0x10); // Antenna // Display Lcd_Comd(0x80); //set Line 1 for (i=0x30 ; i<0x3A ; i++) // Data 0-9 Lcd_Data(i); Lcd_Comd(0xC8); //set line 2 Lcd_Pos("BY M.·¸Á"); while(1) ; //end }