diff --git a/1602LCD_char_display.c b/1602LCD_char_display.c new file mode 100644 index 0000000..9202306 --- /dev/null +++ b/1602LCD_char_display.c @@ -0,0 +1,113 @@ +/* + * Author: Jake Goodwin + * Date: 2022 + * Description: Interfacing with a 1602LCD only with the uc no perifs + */ + +#include +#include +#include +#include + + +#define RS_PORT PORTD +#define RS_PIN PIND0 +#define RS_DDR DDD0 + + +#define RW_PORT PORTD +#define RW_PIN PIND1 +#define RW_DDR DDD1 + + +#define ENA_PORT PORTD +#define ENA_PIN PIND2 +#define ENA_DDR DDD2 + +#define BIT4_PORT PORTD +#define BIT4_PIN PIND3 +#define BIT4_DDR DDD3 + + +#define BIT5_PORT PORTD +#define BIT5_PIN PIND4 +#define BIT5_DDR DDD4 + +#define BIT6_PORT PORTD +#define BIT6_PIN PIND5 +#define BIT6_DDR DDD5 + +#define BIT7_PORT PORTD +#define BIT7_PIN PIND6 +#define BIT7_DDR DDD6 + +#define LED_PIN PINC0 +#define LED_PORT PORTC +#define LED_DDR DDC0 + +//LCD CONNECTIONS +//PIND0 RS, H: data input L: Instruction input +//PIND1 RW, H: read L: write +//PIND2 ENABLE, Enable signal +//PIND3 BIT4 +//PIND4 BIT5 +//PIND5 BIT6 +//PIND6 BIT7 + +//############################# +//FUNCTIONS +//############################# + +void init_lcd(void) { + DDRD |= (1< $@ + +## These targets don't have files named after them +.PHONY: all disassemble disasm eeprom size clean squeaky_clean flash fuses + +all: $(TARGET).hex + +debug: + @echo + @echo "Source files:" $(SOURCES) + @echo "MCU, F_CPU, BAUD:" $(MCU), $(F_CPU), $(BAUD) + @echo + +# Optionally create listing file from .elf +# This creates approximate assembly-language equivalent of your code. +# Useful for debugging time-sensitive bits, +# or making sure the compiler does what you want. +disassemble: $(TARGET).lst + +disasm: disassemble + +# Optionally show how big the resulting program is +size: $(TARGET).elf + $(AVRSIZE) -C --mcu=$(MCU) $(TARGET).elf + +clean: + rm -f $(TARGET).elf $(TARGET).hex $(TARGET).obj \ + $(TARGET).o $(TARGET).d $(TARGET).eep $(TARGET).lst \ + $(TARGET).lss $(TARGET).sym $(TARGET).map $(TARGET)~ \ + $(TARGET).eeprom + +squeaky_clean: + rm -f *.elf *.hex *.obj *.o *.d *.eep *.lst *.lss *.sym *.map *~ *.eeprom + +##########------------------------------------------------------########## +########## Programmer-specific details ########## +########## Flashing code to AVR using avrdude ########## +##########------------------------------------------------------########## + +flash: $(TARGET).hex + $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U flash:w:$< + +## An alias +program: flash + +flash_eeprom: $(TARGET).eeprom + $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U eeprom:w:$< + +avrdude_terminal: + $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nt + +## If you've got multiple programmers that you use, +## you can define them here so that it's easy to switch. +## To invoke, use something like `make flash_arduinoISP` +flash_usbtiny: PROGRAMMER_TYPE = usbtiny +flash_usbtiny: PROGRAMMER_ARGS = # USBTiny works with no further arguments +flash_usbtiny: flash + +flash_usbasp: PROGRAMMER_TYPE = usbasp +flash_usbasp: PROGRAMMER_ARGS = # USBasp works with no further arguments +flash_usbasp: flash + +flash_arduinoISP: PROGRAMMER_TYPE = avrisp +flash_arduinoISP: PROGRAMMER_ARGS = -b 19200 -P /dev/ttyACM0 +## (for windows) flash_arduinoISP: PROGRAMMER_ARGS = -b 19200 -P com5 +flash_arduinoISP: flash + +flash_109: PROGRAMMER_TYPE = avr109 +flash_109: PROGRAMMER_ARGS = -b 9600 -P /dev/ttyUSB0 +flash_109: flash + +##########------------------------------------------------------########## +########## Fuse settings and suitable defaults ########## +##########------------------------------------------------------########## + +## Mega 48, 88, 168, 328 default values +LFUSE = 0x62 # +HFUSE = 0xdf #High fuses +EFUSE = 0x00 # + +## ATtiny85 Settings +#LFUSE = 0x62 +#HFUSE = 0xdf +#EFUSE = 0xff + + + + + +## Generic +FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m + +fuses: + $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) \ + $(PROGRAMMER_ARGS) $(FUSE_STRING) +show_fuses: + $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nv + +## Called with no extra definitions, sets to defaults +set_default_fuses: FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m +set_default_fuses: fuses + +## Set the fuse byte for full-speed mode +## Note: can also be set in firmware for modern chips +set_fast_fuse: LFUSE = 0xE2 +set_fast_fuse: FUSE_STRING = -U lfuse:w:$(LFUSE):m +set_fast_fuse: fuses + +## Set the EESAVE fuse byte to preserve EEPROM across flashes +set_eeprom_save_fuse: HFUSE = 0xD7 +set_eeprom_save_fuse: FUSE_STRING = -U hfuse:w:$(HFUSE):m +set_eeprom_save_fuse: fuses + +## Clear the EESAVE fuse byte +clear_eeprom_save_fuse: FUSE_STRING = -U hfuse:w:$(HFUSE):m +clear_eeprom_save_fuse: fuses