From 3f358c19e5fe1d48285c4a9b3930a942f2f866fe Mon Sep 17 00:00:00 2001 From: Vineet K Date: Sat, 20 Apr 2024 15:42:35 -0400 Subject: [PATCH] import lcd.c from lab 10 --- lcd.c | 194 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 116 insertions(+), 78 deletions(-) diff --git a/lcd.c b/lcd.c index 6d9bd4a..5b8866a 100644 --- a/lcd.c +++ b/lcd.c @@ -1,89 +1,127 @@ -#include +#include //standard AVR header -#define F_CPU 16000000UL -#include +#define F_CPU 16000000UL // THE CPU FREQUENCY +#include //delay header -// Define LCD control pin connections -#define LCD_RS_PIN PB0 -#define LCD_RW_PIN PB1 -#define LCD_E_PIN PB2 -#define LCD_RS_PORT PORTB -#define LCD_RW_PORT PORTB -#define LCD_E_PORT PORTB -// Define LCD data pin connections -#define LCD_DATA_PORT PORTD -#define LCD_DATA_DDR DDRD +#define LCD_DPRT PORTD //LCD DATA PORT +#define LCD_DDDR DDRD //LCD DATA DDR +#define LCD_DPIN PIND //LCD DATA PIN +#define LCD_CPRT PORTB //LCD COMMANDS PORT +#define LCD_CDDR DDRB //LCD COMMANDS DDR +#define LCD_CPIN PINB //LCD COMMANDS PIN +#define LCD_RS 0 //LCD RS +#define LCD_EN 1 //LCD EN -// Function prototypes -void LCD_init(); -void LCD_command(uint8_t cmd); -void LCD_write(uint8_t data); -void LCD_send(char* str); +void lcd_putValue(unsigned char val){ + LCD_DPRT &= 0x0F; + LCD_DPRT |= (val&0xF0); //send cmnd to data port + LCD_CPRT |= (1<