int main(void) { // Switches port init. input / pullup PORTB = 0xFF; DDRB = 0x00; // I2C LCD init I2C_LCD_init(); I2C_LCD_puts(TITLE_STR0); I2C_LCD_setpos(0, 1); I2C_LCD_puts(TITLE_STR1); _delay_ms(2000); I2C_LCD_clear(); while(1) { uint8_t switches = PINB; char lcdBuff[17]; sprintf(lcdBuff, "SW: %x", switches); I2C_LCD_home(); I2C_LCD_puts(TITLE_STR0); I2C_LCD_setpos(0, 1); I2C_LCD_puts(lcdBuff); } }
void main_init(void) { OSC_init(); TRISA = 0b00010000; // x,x,x,Vcap,x,x,x,x TRISB = 0b00110001; // x,x,SDA,SCL,x,x,x,x TRISC = 0b10111010; // RX,TX,D+,D-,Vusb,LED,T1OSI,T1OSO ANCON0 = 0b11111111; // xxx,xxx,xxx,RA5,RA3,RA2,RA1,RA0 ANCON1 = 0b00011111; // VBG,xxx,xxx,RB0,RC2,RB1,RB3,RB2 INTCON2bits.RBPU = 0; // Pull-up enable timer1_init(0, T1OSC); I2C_LCD_init(); }