From 119942f88e12f1106c081ef0eaf10470ee0305fd Mon Sep 17 00:00:00 2001 From: lucic71 Date: Sun, 7 Jun 2020 18:40:26 +0300 Subject: [PATCH] Started LCD --- 16x2_lcd/Makefile | 35 ++++++++++++++++++++++++++++++ 16x2_lcd/lcd.s | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 16x2_lcd/Makefile create mode 100644 16x2_lcd/lcd.s diff --git a/16x2_lcd/Makefile b/16x2_lcd/Makefile new file mode 100644 index 0000000..ae220e5 --- /dev/null +++ b/16x2_lcd/Makefile @@ -0,0 +1,35 @@ +BINARY=lcd + +AS=avr-as +LD=avr-ld +OBJCOPY=avr-objcopy +GDB=avr-gdb + +AVRDUDE=avrdude +AVRDUDE_CONFIG=/etc/avrdude.conf + +TTY=/dev/ttyACM0 + +ARCH=atmega328p + +SIMAVR=simavr + +build: + $(AS) -g -mmcu=$(ARCH) -o $(BINARY).o $(BINARY).s + $(LD) -o $(BINARY).elf $(BINARY).o + $(OBJCOPY) -O ihex -R .eeprom $(BINARY).elf $(BINARY).hex + +upload: + $(AVRDUDE) -C $(AVRDUDE_CONFIG) -p $(ARCH) -c arduino -P $(TTY) -b 115200 -D -U flash:w:$(BINARY).hex:i + +sim: + $(SIMAVR) -m $(ARCH) $(BINARY).elf -g + +debug: + $(GDB) $(BINARY).elf + + +run: build upload + +clean: + ls | grep $(BINARY) | grep -v *.s | xargs rm -f -- diff --git a/16x2_lcd/lcd.s b/16x2_lcd/lcd.s new file mode 100644 index 0000000..03a363f --- /dev/null +++ b/16x2_lcd/lcd.s @@ -0,0 +1,55 @@ +.equ RAMEND, 0x08FF + +.equ SREG, 0x3F +.equ SPL, 0x3D +.equ SPH, 0x3E + +.equ PORTD, 0x0B +.equ DDRD, 0x0A + +.equ PORTB, 0x05 +.equ DDRB, 0x04 + +.equiv PINCONFIG, 24 + +.org 0x0000 + +INIT_MEM: + + ; Description: + ; ----------- + ; + ; Reset the system status in SREG, initialize the stack using SPL and + ; SPH and set output PINs on PORTB. + ; + ; Pins used for DATA will be DIGITAL PIN 1-7 from PORTD and DIGITAL PIN 8 + ; from PORTB. + ; + ; Pins used for REGISTER SELECT, READ/WRITE and ENABLE are DIGITAL PINS + ; 10, 11, respectively 12 from PORTB. + + clr r16 + out SREG, r16 + + ldi r16, lo8(RAMEND) + out SPL, r16 + + ldi r16, hi8(RAMEND) + out SPH, r16 + + ldi r16, 0xFE + out DDRD, r16 + + ldi r16, 0x1C + out DDRB, r16 + +INIT_LCD: + + ldi PINCONFIG, 0x10 + out PORTB, PINCONFIG + + ldi PINCONFIG, 0x70 + out PORTD, PINCONFIG + +MAIN: + rjmp MAIN