6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 8:28 pm

All times are UTC




Post new topic Reply to topic  [ 62 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: Tue Dec 19, 2023 12:24 am 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 2:38 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Welcome, John!


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 3:13 pm 
Offline

Joined: Mon Dec 18, 2023 2:22 pm
Posts: 10
BigDumbDinosaur wrote:
Some notes:

Thank you for taking the time to look and offer such helpful feedback. I'll tie DCDB and DSRB permanently low. CTSB too, for the time being. It would be nice to be able to use CTS/RTS eventually but that's some way away. I've noted your points about IRQB, removing the diodes and reducing the value of R1.

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.

Thanks, George. This ties in with BDD's final point about providing a delay in the link between pins 10 and 12 of U1. I only have the WDC datasheet to work from and it doesn't give that kind of information, so I'm going to measure it myself. I've been sketching out the software this morning but I realise Christmas is hurtling towards me so I'll have to take a break from it soon.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 3:16 pm 
Offline

Joined: Mon Dec 18, 2023 2:22 pm
Posts: 10
Thanks, Ed!


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 3:56 pm 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
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.
Attachment:
aciareceiveinterrupttiming.png
aciareceiveinterrupttiming.png [ 68.37 KiB | Viewed 3640 times ]
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 4:46 pm 
Offline

Joined: Mon Dec 18, 2023 2:22 pm
Posts: 10
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!


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 4:58 pm 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 6:49 pm 
Offline

Joined: Mon Dec 18, 2023 2:22 pm
Posts: 10
Quote:
I would still link RX and TX on one ACIA used for transmitting

Ah, right. I understand now. Thanks, George.

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

Attachment:
65C51mono2.png
65C51mono2.png [ 22.77 KiB | Viewed 3624 times ]


Attachments:
W65C51.s [5.89 KiB]
Downloaded 29 times
Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 6:57 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8504
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 7:40 pm 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 983
Location: Potsdam, DE
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


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 7:53 pm 
Offline

Joined: Mon Dec 18, 2023 2:22 pm
Posts: 10
BigDumbDinosaur wrote:
The transmitter and receiver would gradually drift apart in timing and things would fall apart.

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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 9:20 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8504
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 9:28 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Yeah, seems fine to me... just think about what stop bits are and how they work.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 19, 2023 11:46 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
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?


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 20, 2023 9:03 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 983
Location: Potsdam, DE
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 62 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: