Пример #1
0
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
void LCD_send_data(uint8_t data){
	LCD_send_byte(data, 1);
	LCD_wait();
}
Пример #5
0
void LCD_send_command(uint8_t command){
	LCD_send_byte(command, 0);
	LCD_wait();
}