John-Titor / py68k

M68K emulator based on Musashi, with a Python device model
16 stars 1 forks source link

Having trouble reading 68681 registers #5

Open ziggekatten opened 1 year ago

ziggekatten commented 1 year ago

Is there something I'm missing when trying to use the mc68681? I have no issue writing to it and get console output, but reading data from the recieve buffer always returns 0xff, and reading CRA and SRA always returns 0x00, and MR1A always returns 0x07.

John-Titor commented 1 year ago

Are you using the socket console, or the stdout console (--stdout-console) mode? The latter only supports output, it ignores input.

ziggekatten commented 1 year ago

I'm using the socket console, running a process with --console server

John-Titor commented 1 year ago

I would expect this to work; what host are you running on? The console server is very generic Python/socket code, but there's always a possibility of something odd. I've only tested on macOS.

Note that CRA/CRB are write-only; I would expect reading from them to return nothing useful.

Most of the time, SRx.TXRDY/TXEMT should be set (and generally speaking you shouldn't be putting anything in TBx unless TXRDY is set...), so I'd focus on getting to that point first. If you haven't already, you might try turning on tracing (--trace-everything) and look for accesses to SRA.

ziggekatten commented 1 year ago

Running under Windows (WSL2). Linux (Ubuntu 22.04) does not work (get an write error) but I have yet to troubleshoot that one.

Now, sending stuff from the CPU to the UART is no problem. As soon as I put data in the TBA buffer it's printed at the console. The problem I have is recieving data, and to do that the SRA lowest bit should be 0 if an byte have been recieved and put in the buffer RBA if I have read the datasheet correcly. Nor does the buffer full bit going set when typing in the console.

Screenshot from running my code: image

As yhou can see, SRA is 0x03 all the time, and for some reason RBA contains 0x07, which is weird. It should be empty.

ziggekatten commented 1 year ago

Running under Windows (WSL2). Linux (Ubuntu 22.04) does not work (get an write error) but I have yet to troubleshoot that one.

Now, sending stuff from the CPU to the UART is no problem. As soon as I put data in the TBA buffer it's printed at the console. The problem I have is recieving data, and to do that the SRA lowest bit should be 0 if an byte have been recieved and put in the buffer RBA if I have read the datasheet correcly. Nor does the buffer full bit going set when typing in the console.

Screenshot from running my code: image

As yhou can see, SRA is 0x03 all the time, and for some reason RBA contains 0x07, which is weird. It should be empty.

Ohhhh.....sometimes one should just take some time to get the basics right....I'm writing my stuff in C, and missing an * means reading address instead of value of my pointer....jezz..... the figures you see in the screenshot is the last byte of the pointer address, not the value in the register....

John-Titor commented 1 year ago

That sounds promising. If you work out what's going on with WSL2 please share, since that would be worth fixing.