More debugging – part 4.

November 12th, 2013

Right, I think I finally cracked it. With some help on the forum. And it’s something that’s mentioned in Garth’s tips of the day too – Tip #14 here.

Basically the issue is reading the ACIAs status register changes the register. It clears the interrupt bit. My situation is a little different to that in the tip mentioned as I am only doing interrupt driven receive and polled send. But when sending I still need to check the status register to make sure the transmit buffer is empty.

Doing this made it much more reliable but I can still break it by really hammering it. I tried using interrupt driven transmit again (but with the read the status register once fix) and this is still very fragile. It definitely seems if there is a lot of data coming and going it’s easy to get the ACIA into bad states.

I think the safest way is to stick to polled sends and interrupt driven receive. And to disable interrupts when sending  so there are no clashes there.  Or disable interrupts except for when you want to receive data. Need to experiment there. The receiving routine can beep if it detects errors. So for loading then you can simply adjust the speed until there are no beeps!

I finally realised the random memory corruption I was seeing sometimes before may have been caused by my test code I was uploading. It contained POKEs in it. If I was sending data too fast and characters were being dropped or garbled it’s possible a POKE was being received with no line number. In that case Basic will run it as an immediate command. If the location it was poking too was also corrupt I could have been sticking random things into random memory locations. Very naughty!

I have had enough of punishing this chip now so that’s the compromise I will use. If loading is a little fiddly, well, that’s exactly how things were in the 80s! Anyone who did any loading from cassette tape will remember that. My friend Dave says he can’t remember EVER successfully loading something off tape on his old Apple 2.

So, time to step away from the microcomputer and go do something useful now for a bit!


Comments are closed.