I'm trying to initialize a 16550 and send characters 0 to 255 in an endless loop via a max232 to my PC.
I was expecting some unprintable characters and somewhere in between the whole ASCII char set.
However all I get in putty is gibberish.
I've tried different baud rates 1200, 9600, 38400
I've tried another USB to serial adapter,
I've tried another Crysal osc with the same frequency (1.8432Mhz),
I've tried another 16550 chip (the other is a 16C552 actually),
But still all i get is gibberish so i figured that the problem is likely in my assembly code.
Anyways just in case I've done something wrong with the hardware I attach a rough schematic too.
Data and Address lines that are not shown in the drawing are straight connected to every chip that needs them. All IC's have 100n decoupling capacitors near them.
Does anyone have an idea how to get the UART running correctly? Thanks.
Memory map:
0000-7FFF RAM
8000-BFFF IO
C000-FFFF ROM
Here my code:
Code: Select all
INIT:
LDA #$80 ; DLAB=1 open special control register
STA $8003
LDA #$0C ; $60 = 1200kbps, $0C = 9600kbps, $03 = 38400kbps
STA $8000 ; DLL
LDA #$00
STA $8001 ; DLM
LDA #$03
STA $8003 ; Set 8N1 byte framing: 8-bit data, no parity, 1 stop bit, reset DLAB Flag.
LDY #$00
LOOP:
LDA $8005 ; Fetch the control register.
AND #$20 ; Bit5 will be set to 1 if UART is ready to send.
CMP #$20
BNE LOOP
STY $8000 ; Transmit character in register A to UART.
INY
JMP LOOP