Working LCD!

This commit is contained in:
Daniele Verducci su MatissePenguin 2020-10-24 23:30:50 +02:00
parent c833911cad
commit 01d1e1f6d8
5 changed files with 57 additions and 10 deletions

View File

@ -1,11 +1,9 @@
/* HD44780 Character display debugger */
#define EN 2
#define RS 11
const byte DATA_BUS[] = {10, 9, 8, 7, 6, 5, 4, 3};
#define EN 11
const byte DATA_BUS[] = {3, 4, 5, 6, 7, 8, 9, 10};
void setup() {
pinMode(RS, INPUT);
pinMode(EN, INPUT);
for(int pin=0; pin < 8; pin++) {
pinMode(DATA_BUS[pin], INPUT);
@ -13,9 +11,9 @@ void setup() {
Serial.begin(57600);
Serial.println("HD44780 debugger");
Serial.println("DATA BUS HEX RS EN");
Serial.println("DATA BUS HEX EN");
attachInterrupt(digitalPinToInterrupt(EN), onClk, CHANGE);
attachInterrupt(digitalPinToInterrupt(2), onClk, FALLING);
}
void loop() {}
@ -28,7 +26,10 @@ void onClk() {
data = (data << 1) + b; // Shifta di 1 e aggiunge il bit corrente. Serve per ricostruire il numero da binario
}
char output[30] = {};
sprintf(output, " 0x%02x %c %c", data, digitalRead(RS) ? 'D' : 'I', digitalRead(EN) ? 'H' : 'L');
char output[50] = {};
sprintf(output, " 0x%02x %c",
data,
digitalRead(EN) ? 'D' : 'I'
);
Serial.println(output);
}

5
assembly/Makefile Normal file
View File

@ -0,0 +1,5 @@
bios:
z80asm -i pat80_bios_0.1.asm -o rom.bin
dd if=/dev/zero of=rom.bin bs=1 count=0 seek=8192
minipro -w rom.bin -p "AT28C64B"

View File

@ -4,4 +4,5 @@ Portare binario alla dimensione dell eeprom:
dd if=/dev/zero of=rom.bin bs=1 count=0 seek=8192
Scrivere su EEPROM:
minipro -w rom.bin -p "AT28C64B"
Leggere EEPROM:
minipro -r rom_read.bin -p "AT28C64B"

View File

@ -36,4 +36,3 @@ ld a,%00100001
out (LCD_DATA_REG),a
halt

View File

@ -0,0 +1,41 @@
; SYSTEM CONFIGURATION
LCD_INSTR_REG: EQU %00000000
LCD_DATA_REG: EQU %00000001
; System initialization
call lcd_init
; write characters to display
ld bc, hello_world
call lcd_write ; write string to screen
halt
lcd_init:
;reset procedure
ld a,%00111000
out (LCD_INSTR_REG),a
ld a,%00001000
out (LCD_INSTR_REG),a
ld a,%00000001
out (LCD_INSTR_REG),a
;init procedure
ld a,%00111000
out (LCD_INSTR_REG),a
ld a,%00001110
out (LCD_INSTR_REG),a
ret
lcd_write:
ld a, (bc) ; bc is the pointer to passed string's first char
cp 0 ; compare A content with 0 (subtract 0 from value and set zero flag Z if result is 0)
ret z ; if prev compare is true (Z flag set), string is finished, return
out (LCD_DATA_REG),a ; output char
inc bc ; increment bc to move to next char
jp lcd_write
hello_world:
DB "Lorem ipsum",0 ; null terminated string