6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Nov 12, 2024 3:36 pm

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Fri Sep 30, 2022 11:12 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Hey all!

I'm working on a video showing the W65C51 being added to my breadboard. I know about the various bugs of the device, I've read the various forum threads about it and floobydust's investigation here viewtopic.php?f=4&t=2543. I felt that it was still valuable to build into the first revision of my computer and talk about it in the series, being the simplest UART for a 65xx system that you can buy new at regular distributors (for ease of reproducibility).

Imagine my surprise when, intending to show the Xmit bug on video, I ran the following code and it output perfect data, every time.

Code:
                        acia_init:
                          ; programmatically reset the chip by writing the status register
810d 9c917f               stz IO_1_ACIA_STATUS_REGISTER

                          ; set up the ACIA with
                          ; - baud rate 300 (smallest supported by MCP2221A)
                          ; - no external receiver clock, RxC pin outputs the baud rate
                          ; - 8 bit word length
                          ; - 1 stop bit
8110 a916                 lda # ACIA_CONTROL_BAUD_RATE_300 | ACIA_CONTROL_RECEIVER_CLOCK_BAUD_RATE | ACIA_CONTROL_WORD_LENGTH_8 | ACIA_CONTROL_STOPBIT_1
8112 8d937f               sta IO_1_ACIA_CONTROL_REGISTER

                          ; further set up the ACIA with
                          ; - /DTR = Low
                          ; - Receiver IRQ off
                          ; - /RTS = Low, Transmitter enabled, transmitter IRQ off
                          ; - Echo mode disabled
                          ; - Parity disabled
8115 a90b                 lda # ACIA_COMMAND_DATA_TERMINAL_READY_ASSERT | ACIA_COMMAND_RECEIVER_IRQ_DISABLED | ACIA_COMMAND_TRANSMITTER_CONTROL_REQUEST_TO_SEND_ASSERT_INTERRUPT_DISABLED | ACIA_COMMAND_RECEIVER_ECHO_DISABLED | ACIA_COMMAND_RECEIVER_PARITY_DISABLED
8117 8d927f               sta IO_1_ACIA_COMMAND_REGISTER

811a 60                   rts

                        ; acia_putchar: Sends a byte over serial. Blocking loop until transmit is available.
                        ;
                        ; arguments: A = byte to send
                        acia_putchar:
                          ; move byte to X register
811b aa                   tax

                          ; wait until we can transmit
811c a910                 lda # ACIA_STATUS_TRANSMITTER_DATA_REGISTER_EMPTY
811e 2c917f             - bit IO_1_ACIA_STATUS_REGISTER
8121 f0fb                 beq -

                          ; transmit byta and return
8123 8e907f               stx IO_1_ACIA_DATA_REGISTER
8126 60                   rts


                        ; acia_getchar: Receives a byte over serial. Blocking loop until something is received.
                        ;
                        ; No arguments
                        ; Returns byte in A
                        acia_getchar:
                          ; wait until a byte is available
8127 a908                 lda # ACIA_STATUS_RECEIVER_DATA_REGISTER_FULL
8129 2c917f             - bit IO_1_ACIA_STATUS_REGISTER
812c f0fb                 beq -

                          ; get received byte and return
812e ad907f               lda IO_1_ACIA_DATA_REGISTER
8131 60                   rts


Code:
800d 200d81               jsr acia_init

8010 a948                 lda # "H"
8012 201b81               jsr acia_putchar
8015 a965                 lda # "e"
8017 201b81               jsr acia_putchar
801a a96c                 lda # "l"
801c 201b81               jsr acia_putchar
801f a96c                 lda # "l"
8021 201b81               jsr acia_putchar
8024 a96f                 lda # "o"
8026 201b81               jsr acia_putchar
8029 a92c                 lda # ","
802b 201b81               jsr acia_putchar
802e a920                 lda # " "
8030 201b81               jsr acia_putchar
8033 a957                 lda # "W"
8035 201b81               jsr acia_putchar
8038 a96f                 lda # "o"
803a 201b81               jsr acia_putchar
803d a972                 lda # "r"
803f 201b81               jsr acia_putchar
8042 a96c                 lda # "l"
8044 201b81               jsr acia_putchar
8047 a964                 lda # "d"
8049 201b81               jsr acia_putchar
804c a921                 lda # "!"
804e 201b81               jsr acia_putchar


My putchar routine is doing a loop checking the transmit bit of the status register repeatedly until it clears. And it does, but not before the data has been sent! This reliably prints "Hello, World!" to my terminal. I also checked it at various baud rates from 300 to 115200. I haven't checked with IRQs yet.

My CPU is running at 4MHz and so the successive calls to putchar happen well before bytes could be transmitted. 22 cycles happen between storing the byte in the transmit register and reading the status register in the next invocation, that's 5.5us at 4MHz. At 115200, it takes 86us for a byte to be transmitted.

So I'm confused. Did WDC fix their chips? Am I on an earlier revision that does not have the bug? What gives? :D

Attached is a pic of the chip and its markings, not sure how to interpret them in terms of date code or revision.

Attachment:
IMG_6896.jpg
IMG_6896.jpg [ 421.09 KiB | Viewed 1851 times ]

_________________
BB816 Computer YouTube series


Last edited by akohlbecker on Sat Oct 01, 2022 11:26 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 30, 2022 11:48 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Huh, it looks like floobydust was using a W65C51N and I'm on a W65C51S.

Comparing the datasheets, the one for the N version mentions the status xmit bit being always set, and that parity needs to not be used. The datasheet for the S version does not include those warnings. Furthermore, there is an errata section, attached here:

Attachment:
Screenshot 2022-10-01 at 01.46.28.png
Screenshot 2022-10-01 at 01.46.28.png [ 704.1 KiB | Viewed 1847 times ]


I'm on version SA0615A, which seems to be the latest, and has a few issues fixed. It does look like there is still a minor known issue though. I'm not sure what "the initial one or two writes to the transmitter may intermittently shift incorrectly depending on the circuit design used." means exactly.

Attachment:
w65c51s-June 2007.pdf [427.85 KiB]
Downloaded 36 times

_________________
BB816 Computer YouTube series


Last edited by akohlbecker on Sat Oct 01, 2022 12:13 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 12:03 am 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
The plot thickens, and the page for the S version is not linked directly on WDC's website, but you can find it through google https://www.westerndesigncenter.com/wdc ... s-chip.php. It seems available as engineering samples only

Mouser only has the N version.

So it looks like I got lucky with my chips :-D Got them from Quest Components 18 months ago, sadly they don't have any more left.

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 12:06 am 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
I found an earlier revision of the datasheet for the S version, dated July 2006, that shows errata for presumably earlier runs of the chips. Might be useful, so saving it here.

Attachment:
w65c51s-July 2006.pdf [1.28 MiB]
Downloaded 47 times


Attachment:
Screenshot 2022-10-01 at 02.04.53.png
Screenshot 2022-10-01 at 02.04.53.png [ 760.46 KiB | Viewed 1844 times ]


Attachment:
Screenshot 2022-10-01 at 02.04.58.png
Screenshot 2022-10-01 at 02.04.58.png [ 478.62 KiB | Viewed 1844 times ]

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 12:10 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
Interesting. Where did you find a datasheet for '51S? Their page https://wdc65xx.com/integrated-circuit, and also https://www.westerndesigncenter.com/wdc/chips.php, only have the 51N.

_________________
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: Sat Oct 01, 2022 5:27 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8482
Location: Midwestern USA
You have an early engineering sample, not a production part. I didn’t think any of those were in the wild.

Attached is the data sheet for currently-available production parts.

Attachment:
uart_65C51.pdf [929.68 KiB]
Downloaded 37 times

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


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 10:07 am 
Offline

Joined: Wed Jan 08, 2014 3:31 pm
Posts: 578
This is maddening. A version of this part that works, his PDF is dated 2007, but it hasn't been released? So we're stuck with the broken version.


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 11:30 am 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
GARTHWILSON wrote:
Interesting. Where did you find a datasheet for '51S? Their page https://wdc65xx.com/integrated-circuit, and also https://www.westerndesigncenter.com/wdc/chips.php, only have the 51N.


In case you haven't seen it I think we posted at the same time, I linked to the page above.

Martin_H wrote:
This is maddening. A version of this part that works, his PDF is dated 2007, but it hasn't been released? So we're stuck with the broken version.


Yeah, it sucks. Note that the version I have still seems to have some issue with transmit in "some circuit designs". I'm not sure what that means, and if it makes it flaky enough that it would be best to avoid.

But yeah clearly there was some effort at one point to redesign this chip, and it never saw the light of day. I might reach out to WDC to ask for more details. Anyone here has a direct line to someone technical there, or should I just go through the regular contact form?

It is ironic, because I can't use these on my videos, and I now have to go and buy the buggy version... :roll:

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 11:49 am 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
Isn't it better to just use a different part? Does the 6551 have some benefit over the other parts that makes up for the bug?


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 2:33 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
Well, you do have an engineering sample W65C51 UART. Several years ago Bill Mensch sent me 6 engineering samples before the current part was put into production. The one you have is the same as two of mine... and yes, I have one working, but the second one has some odd issues. I've run the chip with a can oscillator of 3.6864 MHz for a quicker baud rate and with a CPU clock up to 10MHz without any issues. I'm also using interrupt-driven transmit and receive. I wouldn't count on finding more of these, and even if you do, there's the possibility that all will not function the same.

Attachment:
W65C51S-PCB.jpg
W65C51S-PCB.jpg [ 737.92 KiB | Viewed 1780 times ]


I would strongly suggest going to a different chip if you plan on making more than a single system. The NXP (D)UARTs are excellent and have more functions and higher baud rates available.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 01, 2022 9:38 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
gfoot wrote:
Isn't it better to just use a different part? Does the 6551 have some benefit over the other parts that makes up for the bug?


There are multiple reasons, for my videos series specifically.

For one, I want to build a computer that any viewer can reproduce on breadboards. This means using in-production or easily swappable parts. It also means using DIP ICs only. Now the only DIP UARTs you can get at Mouser are the W65C51N, the MAX3100, and some Z80 family chip. That is not a lot of options to work with, unfortunately.
I'm also making educational videos, so I need something that can easily interface with the CPU, so the focus can be on what the UART does and not on the interface. That makes the MAX3100 with its SPI bus a more advanced option, maybe for later revisions.
Showing the bug and how to work around it also is good educational content.

Of course, if you can get an R65C51, that's probably a better version, but not everyone wants to deal with second-hand chips. It is also specced for a lower bus frequency, which means there could be the additional issue of wait states to deal with. I have plans to later upgrade to a TL16C550CN. The DIP version is still findable new, but not in regular distributors, however. It will be a nice upgrade.

With the VIA's PB6 input trick for a timed tx interrupt, I think the W65C51N will honestly work well enough. It is a fine option for anyone making a breadboard computer as long as you know this trick, in my opinion.

floobydust wrote:
Well, you do have an engineering sample W65C51 UART. Several years ago Bill Mensch sent me 6 engineering samples before the current part was put into production. The one you have is the same as two of mine... and yes, I have one working, but the second one has some odd issues. I've run the chip with a can oscillator of 3.6864 MHz for a quicker baud rate and with a CPU clock up to 10MHz without any issues. I'm also using interrupt-driven transmit and receive. I wouldn't count on finding more of these, and even if you do, there's the possibility that all will not function the same.

Attachment:
W65C51S-PCB.jpg


I would strongly suggest going to a different chip if you plan on making more than a single system. The NXP (D)UARTs are excellent and have more functions and higher baud rates available.


Cool to see I'm not the only one with these!

Yeah I agree I'm not sure how much I should trust these devices, there is at least one known errata and there could be more given that they haven't really been tested by a lot of people. I will definitely use them in personal projects but not on the videos.

See above for why NXP UARTs are not an option for me at the moment :-)

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 02, 2022 10:51 am 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
Sadly, many of the DIP parts are gong away, being phased out by the manufacturer. The same can be said for 5-volts parts, as 3.3V is more common these days, but even these are being replaced with even lower voltage semiconductors.

Needless to say, getting new DIP parts will continue to be more difficult over time. Even UART type chips are starting to be phased out, as automotive moves towards CAN bus and higher speed intercommunication between the various control modules. You probably recall BDDs recent post about NXP discontinuing their UARTs:

viewtopic.php?f=4&t=7289&hilit=NXP#p94725

I think one can still find the older NXP (Philips) SCC2691 UART in a 24-pin DIP. I've been using these for several years now.... they run fine up to 6MHz CPU clock rates and can handle 115.2K baud rates natively and have a 16-bit counter/timer. It's just another possible option for getting a serial console on a breadboard build.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 02, 2022 2:17 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
floobydust wrote:
Sadly, many of the DIP parts are gong away, being phased out by the manufacturer.
Yup. :|

But, FWIW, many of these parts remain available. I did some poking around and ended up on Jameco's site. This page lists 7 different UARTs in DIP packages. And I'm guessing other supplies carry these as well.

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 02, 2022 6:19 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8482
Location: Midwestern USA
Dr Jefyll wrote:
This page lists 7 different UARTs in DIP packages. And I'm guessing other supplies carry these as well.

Of the ones Jameco offers, the 16C550CN is the only one that I’d give any consideration. The others are extremely obsolete and lame. Retro in UARTs is not good, in my opinion.

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

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