예제 #1
0
파일: 24C16.c 프로젝트: dodelal/quadro_c
void main (void)
{
	//init LCD
	LCD_init();
	//set TWBR = 32 for 100kHz SCL @ 8MHz
	TWI_init(32, 0);
	
	//write 0x55 @ 513 and print return value on LCD
	LCD_puthex(EE_write_byte(513, 0x55));
	//send stop
	TWI_stop();
	LCD_wait();
	LCD_putchar(' ');
	//wait for the EEPROM to finish the write operation
	TWI_wait(EE_ADDR);
	//read the write location again and print return code on LCD
	LCD_puthex(EE_read_byte(513));
	LCD_wait();
	LCD_putchar(' ');
	//print the value read from the EEPROM on the LCD
	LCD_puthex(TWDR);
	TWI_stop();
	//LCD should now show "0x00 0x00 0x55_"
	//where the _ is the blinking cursor.
}
예제 #2
0
void LCD_command(unsigned char command){
	
	LCD_wait();  // is it still busy?
	DDRD = 0xFF;  // data port as output
	PORTC &= ~(1<<LCD_RS);  //RS low for Command
	PORTC |= (1<<LCD_E);    //Enable pin high
	PORTD = command;         // put data on Port
	asm volatile ("nop");
	asm volatile ("nop");
	asm volatile ("nop");
	asm volatile ("nop");    
	PORTC &= ~(1<<LCD_E);   //Enable Pin Low
	DDRD = 0;                // release bus
}
예제 #3
0
void LCD_putchar(unsigned char data){
	LCD_wait();  // is it busy?
	//PortA is output
	DDRD = 0xFF;

	//RS high for data and Enable high
	PORTC |= ((1<<LCD_RS)|(1<<LCD_E));
		//put data on bus
	PORTD = data;
	/*the number of nops required varies with your clock frequency, 
	Can be altered */
	asm volatile ("nop");
	asm volatile ("nop");
	asm volatile ("nop");
	asm volatile ("nop");
	// Enable low again
	PORTC &= ~(1<<LCD_E);
	//release port
	DDRD = 0;
}
예제 #4
0
파일: hd44780.c 프로젝트: stsrc/THD_gauge
void LCD_send_data(uint8_t data){
	LCD_send_byte(data, 1);
	LCD_wait();
}
예제 #5
0
파일: hd44780.c 프로젝트: stsrc/THD_gauge
void LCD_send_command(uint8_t command){
	LCD_send_byte(command, 0);
	LCD_wait();
}