6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Apr 29, 2024 5:33 pm

All times are UTC




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Parts bin UART receiver
PostPosted: Mon Apr 01, 2024 6:51 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
Because why not? Even though it's April first, this is serious... and probably the world's most brain dead UART receiver. It samples properly in the centre of the bit period but doesn't do exciting things like checking for a full start bit or stop bit, or indeed overflows if you fail to read it in time.

With no buffer you need to read the result within ten bit periods (86us for 115,200), so unless you're sitting in a tight loop waiting, an interrupt is probably the only practical option.

The intent is to use it as a receiver immediately after an FT232 so the signal will be clean and correctly timed (though the 16x master clock allows the usual 5% differential timing error).

<pdf removed; see below>

Enjoy :mrgreen:

Neil

Edit: To clarify: the aim with this small design is to use standard 74 family parts, easily available in through hole or SOIC. So it's ended up with four ttl chips and a spare AND gate, all pretty common parts I think.


Last edited by barnacle on Mon Apr 01, 2024 11:28 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 01, 2024 11:26 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
Minor change to prevent data bus being driven when not required.

<pdf deleted, see below>

Neil


Last edited by barnacle on Tue Apr 02, 2024 6:09 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 01, 2024 12:22 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Bravo! (Just four DIP chips - a '393, a '74, an '00 and a '574)

Edit: oops! Closer to five.


Last edited by BigEd on Mon Apr 01, 2024 1:04 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 01, 2024 12:49 pm 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
Four and a quarter: you forgot the '164 :mrgreen:

Neil


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 01, 2024 1:04 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
oops!


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 01, 2024 1:07 pm 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1076
Location: Albuquerque NM USA
Great job! Such a minimal serial receiver can go into a small CPLD while saving rest of macrocell resources for other functions. Minimal, yet functional is the way to pack lots of features into a small CPLD.
Bill


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 01, 2024 1:25 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 745
Location: Germany
how does this differ from something like the SN74LV8153N? (besides the '8153 not requiring a clock)


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 01, 2024 1:44 pm 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
It's similar, but the '8153 requires two properly formatted UART words to give one eight-bit output. The received data contains three bits of target address which has to match the '8153 address pins. That's how I loaded my recent-ish romless SBC, with separate '8153s to store the data and address, using the data received output to write the data into memory.

But it takes a carefully crafted conversion from a hex/bin to an object file to get the right data in the right place.

This just takes a standard UART-232 stream (logic levels, not RS-232 levels) and outputs it one bit at a time. (Also this will work I suspect well in excess of 115,200 while the '8153 is restricted to about 20,000, and required a shade over four words per memory write in my application.)

Apples and oranges, I think.

Neil


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 02, 2024 6:08 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
Whoops, another minor issue sorted: it helps no end if the data in actually goes to the '164 :mrgreen:

<file deleted, see below>

Neil


Last edited by barnacle on Thu Apr 11, 2024 7:31 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 11, 2024 7:11 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
So... I finally got round to building it, and it works.

Fifty percent of the time...

It looks like there's a race hazard I hadn't thought of. The idea is that the sequence starts when the low going edge of the start bit sets U2A, clearing the ~Q output and enabling the counter U1. Every time its Q3 output goes high, at count 8, the current input signal level is clocked into U3. When it goes low again, U1B increments its count. When that count is nine, it asynchronously resets U2A (and also triggers the data latch U4 and sets the ~RXF flag), which resets U1 back to zero.

So after nine counts, nine bits of data have been clocked in, including the start bit which by now has been discarded; the received byte has been latched, and the rx received bit has been set. Now we're waiting for the next start bit, since we're now looking at the stop bit.

Or are we? It appears that depending on the phase of the master (1.8MHz) clock at the time of the first start bit, and the relative speed of the data source clock, it is possible for the counters to reset a few nanoseconds before the rising edge of the stop bit. And that's a problem, because in that case, U2A is in an indeterminate state. Whichever of the ~S and ~R resets rises last will rule, and if the input is still low when the reset pulse rises, then things will immediately start counting again... straight into receiving an all-ones signal.

The issue is down to the relative timings of the serial clock and the count; one is in the middle of the bit and one at the end; sometimes the one at the end arrives too soon.

There is an easy answer, I think, which I'll check this morning; a three input NAND to replace U5A. That should inhibit the reset until the stop bit is high. If that doesn't work, I'll need to look at the count detection logic a little harder.

Neil


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 11, 2024 2:55 pm 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
Nand that makes all the difference (sorry!)
Two words read due to the end of the last bit being read as a new start bit (so eighteen clocks).
Attachment:
DS1Z_QuickPrint47.png
DS1Z_QuickPrint47.png [ 46.45 KiB | Viewed 1218 times ]


And with the reset inhibited until the input goes high (i.e. the stop bit starts), just the nine clocks for a single read that we expect.
Attachment:
DS1Z_QuickPrint48.png
DS1Z_QuickPrint48.png [ 42.55 KiB | Viewed 1218 times ]


Here's the circuit built on my dual-mode proto board, the oscillator at the bottom, the serial chip is the only SOIC on here. I didn't bother with the latch at this point.
Attachment:
1712846250731.jpg
1712846250731.jpg [ 675.63 KiB | Viewed 1218 times ]


Not as small as a single chip solution, but as an input only serial port it's handy (and not limited by system clock speed) and cheap :mrgreen:

Neil


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 11, 2024 7:33 pm 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
And a hopefully final correct circuit diagram. :roll:

Attachment:
discrete_uart_rx.pdf [98.63 KiB]
Downloaded 18 times


Neil


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 11, 2024 9:27 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8155
Location: Midwestern USA
barnacle wrote:
And a hopefully final correct circuit diagram. :roll:

So when will we be seeing the TxD side of your Frankenstein UART?  :D

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 12, 2024 4:58 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 664
Location: Potsdam, DE
Hmm... well that's the easy part, probably. Lemme think on it... I suspect the basic idea could be very similar, but I should really count to ten to include the stop bit to keep the far end happy. The start bit may be an issue.

Neil


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 12, 2024 10:45 am 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1076
Location: Albuquerque NM USA
I have it implemented in CPLD as a 74165 library part plus a little bit of logic dealing with the start bit, just like you said.
Bill


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 58 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: