I was able to advance my project a little bit.
HD44780 library partially works. Screen is initialized and cleared by init() function and I can send characters.
However something weird happens when I try to send entire character string at once. Screen is literally flooded with "6".
Any idea? Code is written in C and quite simple, so for now I ran out of ideas...
Is busy flag checking implemented correctly?
EDIT:
This is weird... This is not about busy flag. I tried to replace with with relatively long delay (50 ms) after writing the byte inside hd44780_putc() function. I was to observe screen being filled with "6". So there must be a problem somewhere inside puts function. I include also compiled version in assembly. Any ideas?
EDIT2:
I also noticed another weird thing. Standard C functions itoa/utoa and sprintf do not work correctly. I try to increment a uint16_t variable in every iteration of the main loop, and then display it on the LCD. itoa/utoa shows "0" for a while ant then "256". Sprintf doesn't show anything ang - program freezes.
Do I need to include something into my program to compile code using those functions?
Code: Select all
#define HD_CMD (*(uint8_t*)0xA380)
#define HD_DATA (*(uint8_t*)0xA381)
void hd44780_putc (char c) {
while (HD_CMD & 0x80);
HD_DATA = c;
}
void hd44780_puts (char *str) {
while (*str) {
hd44780_putc(*str);
str++;
}
}
; ---------------------------------------------------------------
; void __near__ hd44780_puts (__near__ unsigned char *)
; ---------------------------------------------------------------
.segment "CODE"
.proc _hd44780_puts: near
.segment "CODE"
jsr pushax
jmp L0029
L0027: jsr ldax0sp
sta ptr1
stx ptr1+1
ldy #$00
lda (ptr1),y
jsr _hd44780_putc
jsr ldax0sp
jsr incax1
jsr stax0sp
L0029: jsr ldax0sp
sta ptr1
stx ptr1+1
ldy #$00
lda (ptr1),y
bne L0027
jmp incsp2
.endproc