Thank you for the feedback!
leepivonka wrote:
at 403a: error -----------------------------------------------
403a & 403f don't wrap the same way as at 40f1 - it'll go to values that the interrupt handler can never get to.
The interrupt handler will keep retransmitting old bytes trying to get there.
at 4012: error ------------------------------------------------
4012 doesn't wrap the same way as at 40c1,
I was already suspecting it had something to do with the index wrapping?
leepivonka wrote:
Do nx_rx_get_a, nx_tx_get_a, nx_rx_put_a, nx_tx_put_a get initialized somewhere not shown?
If they have random values at startup, you'll get random characters received & transmitted when you start up.
I set them to zero in the nx_init routine at $410b:
Code:
00410B 2 A2 00 ldx #$00
00410D 2 @nextAddr:
00410D 2 74 20 stz nx_zeropage, X
00410F 2 E8 inx
004110 2 E0 20 cpx #$20 ; Reserve $20 (32) bytes and clear these
004112 2 D0 F9 bne @nextAddr
leepivonka wrote:
at nx_irq: error? ---------------------------------------------
Interrupted routine's registers need to be saved before this code executes - is this just not shown?
It should be the reverse of the register restores at nx_irq_end: . )
The registers are pushed/saved in the IRQ routine higher in ROM
Code:
00FDB3 2 handler_nirq:
00FDB3 2 8B phb ; Save current DB
00FDB4 2 0B phd ; Save current DP
00FDB5 2 C2 30 longr ; 16-bit registers
00FDB7 2 48 pha ; Save .A, .X and .Y
00FDB8 2 DA phx
00FDB9 2 5A phy
00FDBA 2 ;-----------------------
00FDBA 2 ; Contents of stack
00FDBA 2 ;
00FDBA 2 ;irq_yreg = 1 ; 16 bit .Y
00FDBA 2 ;irq_xreg = irq_yreg + s_word ; 16 bit .X
00FDBA 2 ;irq_areg = irq_xreg + s_word ; 16 bit .A
00FDBA 2 ;irq_dpreg = irq_areg + s_word ; DP
00FDBA 2 ;irq_dbreg = irq_dpreg + s_mpudpx ; DBR
00FDBA 2 ; pushed by hardware
00FDBA 2 ;irq_srreg = irq_dbreg + s_mpudbx ; SR
00FDBA 2 ;irq_pcreg = irq_srreg + s_mpusrx ; PC
00FDBA 2 ;irq_pbreg = irq_pcreg + s_mpupcx ; PBR
00FDBA 2 ;-----------------------
00FDBA 2 6C D8 02 jmp (VECTOR_INT) ; Jump to (indirect) vector
leepivonka wrote:
This doesn't match the stack contents here.
DP is 2byte.
Hardware pushes P (SR), then PBR, then PC.
; stack now contains
; +13 saved CPU status register
; +12 saved program bank
; +10 saved PC
; +09 saved data bank
; +07 saved DPR
; +05 saved A
; +03 saved X
; +01 saved Y
Doesn't the 65816 not first push the Program bank register, PC and last Processor Status register?
leepivonka wrote:
I think this UART has rx & tx FIFOs more than 1 byte deep. You could process multiple bytes in the interrupt routines if you want them to use less CPU time.
This is something I want to look into later on....