Working around the W65C51 transmit buffer empty bug
Re: Working around the W65C51 transmit buffer empty bug
One thing to check perhaps is the exact timing. I have a feeling the receive interrupt fires halfway through the stop bit, which might be too soon to send the next byte.
Re: Working around the W65C51 transmit buffer empty bug
Welcome, John!
Re: Working around the W65C51 transmit buffer empty bug
BigDumbDinosaur wrote:
Some notes:
gfoot wrote:
One thing to check perhaps is the exact timing. I have a feeling the receive interrupt fires halfway through the stop bit, which might be too soon to send the next byte.
Re: Working around the W65C51 transmit buffer empty bug
This datasheet shows on page 16, figure 6, what continuous receive looks like, and states that the receive interrupt occurs 9/16 of the way through the last stop bit.
One way to delay this more or less in software would be to configure the dummy reciever to expect two stop bits rather than just one - then this interrupt will occur after about one-and-a-half stop bits, when it's already safe to write the next character to the other ACIA straight away without clobbering anything.
Re: Working around the W65C51 transmit buffer empty bug
Thanks George. That's a much more comprehensive data sheet than the one currently available from WDC's site (dated August 21, 2021). I'll implement your suggestion, which means I'll have to revert to using the Rx part of U2 as the dummy and, no doubt, confuse myself in the process!
Re: Working around the W65C51 transmit buffer empty bug
I would still link RX and TX on one ACIA used for transmitting, with 8-N-2, and use the other one for receiving with 8-N-1 - also configuring the other end of the line to 8-N 1 as usual. I don't think it will work the other way around as the receiver would be expecting 8-N-2, so you'd need to configure the other end of the line as 8-N-2, and then you'd also need to transmit 8-N-2 but you're back to square one as you might be truncating those two stop bits a little. Overall you need the line to be principally configured as 8-N-1, though you'll send slightly longer stop phases in practice.
Re: Working around the W65C51 transmit buffer empty bug
Quote:
I would still link RX and TX on one ACIA used for transmitting
The attachments show where I am at the moment. None of this is tested yet and the code isn't complete so it isn't ready to assemble, but it should show where I'm aiming. I'm going to have to put it to one side for now because I'm under pressure to return to the real world for a while!
- John
- Attachments
-
- W65C51.s
- (5.89 KiB) Downloaded 47 times
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Working around the W65C51 transmit buffer empty bug
gfoot wrote:
One way to delay this more or less in software would be to configure the dummy reciever to expect two stop bits rather than just one - then this interrupt will occur after about one-and-a-half stop bits, when it's already safe to write the next character to the other ACIA straight away without clobbering anything.
That won’t work. The transmitter and receiver would gradually drift apart in timing and things would fall apart.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Working around the W65C51 transmit buffer empty bug
What am I missing, BDD? The transmitter isn't going to get new data to transmit until the receiver says it can, half way through the second 'stop' bit. So it should stay in sync since that will retrigger a new rx state with associated interrupt.
Neil
Neil
Re: Working around the W65C51 transmit buffer empty bug
BigDumbDinosaur wrote:
The transmitter and receiver would gradually drift apart in timing and things would fall apart.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Working around the W65C51 transmit buffer empty bug
John_M wrote:
I'm not sure which transmitter/receiver pair you're referring to, but I assume you mean the Tx in U1 which is set to 8-N-2 and the Rx in the external PC that's set to 8-N-1? Doesn't that Rx simply see an 8-N-2 data stream as 8-N-1 with a short period of idle time at the end of each character, as George suggested, since stop bits have the same polarity as idle time? It is, after all, an asynchronous protocol.
Dunno what will happen. In all the years I've worked with TIA-232, mismatched formats have always ended up with garbage at the receiver end.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Working around the W65C51 transmit buffer empty bug
Yeah, seems fine to me... just think about what stop bits are and how they work.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Working around the W65C51 transmit buffer empty bug
The original "solution," years ago when the bug was discovered, was to use a delay loop to make sure you don't give the ACIA the next byte to send before it's ready for it. The receive interrupt solution, if its generating the interrupt only halfway into the stop bit time were truly a problem, could be fixed up with another delay loop, and this delay would be only about 5% as long as the original, so the processor still gets most of its time back to do other things. (I'm sure others have thought of this too, but I didn't see anyone saying it yet.)
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Working around the W65C51 transmit buffer empty bug
It occurs to me that with a fast transmit speed, one might rely on the received interrupt half way through the first stop bit, and then entering a wait for tx empty. Worst case that's only going to be half a bit - say five microseconds at 115200 baud. And in that time is the inescapable interrupt response time anyway.
So you're going to be getting ~95% of the byte time available for other functions, which is a pretty low overhead.
(It also occurs to me that I've almost never relied on interrupts for tx anyway; rx, yes, usually to a buffer, but I tend to use a blocking transmit.)
Neil
So you're going to be getting ~95% of the byte time available for other functions, which is a pretty low overhead.
(It also occurs to me that I've almost never relied on interrupts for tx anyway; rx, yes, usually to a buffer, but I tend to use a blocking transmit.)
Neil