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

All times are UTC




Post new topic Reply to topic  [ 55 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: Fri Jun 21, 2024 8:08 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
My 65xx-oriented RS-232 primer at http://wilsonminesco.com/RS-232/RS-232primer.html tells of the hardware workarounds suggested by forum members GaBuZoMeu and John_M which allow using interrupts again and not wasting processor time in delay loops, and also addresses differences between the NMOS and (non-WDC) CMOS 51's.  It also tells of the data corruption matter you mention regarding making CTS go false during the transmission of an already-started frame, a problem that was corrected on the CMOS version.

_________________
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: Fri Jun 21, 2024 8:11 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8503
Location: Midwestern USA
jgharston wrote:
I've been doing a bit more investigation about working with the 6551 as used on the BenEater 6502 SBC. This is all considering polled I/O. Does the following make sense...

In lieu of a flow chart, the program flow with a properly-functioning 6551 would be:

  1. If the transmitter is idle:

    1. If CTS is asserted:

      1. Write a datum to transmitter.
      2. Adjust queue index (or pointer).
      3. Exit.

    2. If CTS is deasserted:

      1. Defer transmission.
      2. Exit.

  2. If transmitter is busy:

    1. Defer transmission.
    2. Exit.

In the case of the WDC 65C51, the “transmitter is idle/busy” test is not possible by ordinary means, since the TxD status bit is always set.  The logical thing to do is to arrange for a timer (e.g., VIA timer) running in one-shot mode to generate an IRQ some time after writing to the transmitter, with said IRQ indicating it is safe to write the next datum.  The timer would be started immediately after writing a datum and would run out N+1 bit times after transmission has started.  Such an arrangement would give you a quasi-interrupt-driven TxD capability, allowing the MPU to attend to the foreground in between datum transmissions.  Garth also mentions other alternatives.

The receive side is simpler, since RxD status does work in the WDC UART.  Your main concern is in managing RTS so you don’t overflow your receive queue.  In my POC unit’s firmware, I deassert RTS when the queue fill level reaches ~80 percent and assert RTS when the fill level drops to ~60 percent.  I picked those numbers after some experimentation with different TIA-232 devices, e.g., a printer and a modem, revealed that response to their CTS being deasserted was on the slow side.  As always, YMMV.

The fundamental problem is the 65C51 is a lousy UART and no amount of clever programming will ever change that.  Much better UARTs exist.

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


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 22, 2024 2:35 am 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1117
Location: Albuquerque NM USA
It is interesting to note that completely unaware of W65C51 limitation, I’ve designed a CPLD to emulate 6850 ACIA which is very similar to 6551. While the design fitted the small CPLD, I wanted to use the CPLD as the glue logic for processor, so I was forced to pare back functionalities including removing the serial transmitter shift register and associated control/status logic, and replaced it with a bit-bang transmit. The resulting serial port operated very similar to W65C51 with double-buffered serial receiver in hardware and bitbang transmitter controlled with software wait loop. It is fixed at 115200N81 and worked with 30Mhz 6502 without wait state. The logic also fitted inside a 64-macrocell CPLD with plenty room for other functions. It became my standard serial port library module. So, yes, W65C51 is a lousy UART, but the software workaround for it can resulted in simplified hardware that has application in smaller programmable logic. I continue to read the discussions about W65C51 with interests.
Bill


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 22, 2024 5:29 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
That sounds great Bill, is there a place to look at your source?


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 22, 2024 6:52 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8503
Location: Midwestern USA
plasmo wrote:
It is interesting to note that completely unaware of W65C51 limitation, I’ve designed a CPLD to emulate 6850 ACIA which is very similar to 6551...

Talk about being a glutton for punishment!  :D

I too would be interested in seeing the code for doing a 6850 in a CPLD, if for no other reason that to see how you handled serialization and de-serialization.

Interesting thing about the 6850 is that in some ways it’s more primitive than the 6551, and in other ways more advanced.  The main thing about the 6850 I always found annoying was the absence of an on-chip bit rate generator and the lack of a hardware reset input.  The hardware reset can be simulated to some extent by writing the master reset bit pattern into the counter division bits in the control register (although that may not clear a “jam” in some cases—only power cycling will do that).  Providing a bit rate generator, on the other hand, is a pain in the posterior.  In that respect, the 6551 is superior to the 6850.

On the other hand, the 6850’s behavior vis a vis CTS and DCD is more intelligent than that of the 6551, not requiring as much software logic.  Squelching the 6850 transmitter IRQ is considerably easier when there is nothing to send.  Furthermore, the 6850 doesn’t corrupt an outgoing datum when the remote station deasserts RTS.

That said, I still wouldn’t use either one.  I’ve been irrevocably spoiled by UARTs that work right, have FIFOs, offer much more configuration flexibility, will operate at much higher bus speeds and have multiple channels.  :mrgreen:

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


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 22, 2024 9:01 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 983
Location: Potsdam, DE
Tsk, the youth of today... when I were a lad we didn't even have UARTs, we had to wave flags from hilltops, that we had to climb in the snow, uphill both ways...

Neil :mrgreen:


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 22, 2024 9:56 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8503
Location: Midwestern USA
barnacle wrote:
Tsk, the youth of today... when I were a lad we didn't even have UARTs, we had to wave flags from hilltops, that we had to climb in the snow, uphill both ways...

Neil :mrgreen:

Ha!

In my day, we used smoke signals, just like they do at the Vatican when it’s time to choose a new pope.  :D  In fact, it was I who developed the smoke signal code in use by the cardinals.  :shock:

If you believe that, then may I interest you in my ocean-front cottage located in Austria?  :twisted:

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


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 22, 2024 12:51 pm 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1117
Location: Albuquerque NM USA
I talked about the design of CPLD including the serial port in this rather long thread, viewtopic.php?f=6&t=6440 . Homepage is here and it has a PDF schematic of the CPLD design. It has been several years since I looked at the schematic, so I see I've a very simple version of the serial port buried in the middle of the schematic. The CPU clock is multiple of 1.8432MHz, so bit rate generator is just divided-by-N of CPU clock. No hardware serializer because it is done in software via bit-banging. Second page of the schematic shows the details of hardware receiver. The serial port is a small part of the CPLD which has RAM decode, 64-byte ROM, I2C, compact flash interface, all fitted inside an EPM7064S which is equivalent to ATF1504. The simplicity of the design allows the hardware to run fast; this design has been overclocked to over 30MHz.
The Z80 equivalent of the serial port is more complete because the targeted software auto-detect serial device, so I need to have correct emulation of software reset, interrupt generation, hardware handshakes in order to "fool" the software. Good thing about programmable logic is the device's features can be tailored to a particular application, thus reducing required logic.

A systematic approach to smoke signalling is integrate it into guard towers built on top of hills and connect the guard towers via tall walls, top of wall is flat to support rapid deployment of troops. It had been around for couple thousands of years.
Bill


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 22, 2024 12:53 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
(Thanks for the pointers!)


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 25, 2024 2:40 pm 
Offline

Joined: Sun Feb 22, 2004 9:01 pm
Posts: 108
BigDumbDinosaur wrote:
The main thing about the 6850 I always found annoying was the absence of an on-chip bit rate generator...

On the other hand, the 6850’s behavior vis a vis CTS and DCD is more intelligent than that of the 6551...
Yes, having "grown up" with the 6850, I'm so used to things like CTS propagating into TxRDY, so you don't have to test for CTS yourself, you just have to test for TxRDY. I can see how people get spoiled with UARTs that have their own baud generator though. :)

I'm only researching 6551 coding to add it to the options available for some of my code after discovering it via the BenEater system. From this and discussion here I've so far written up 6551poll.asm and made a start on IRQ-driver sample code.

(I've discovered somebody using a 6532 for serial I/O, so I've pencilled in looking at that later.)

With the BenEater also having a 6522 it's possible to use that to finagle a TxRDY signal. My first thought was programming it to provide a centisecond counter (which is usually a basic feature of my systems) and using that to trigger a countdown. Then a quick bit of scribbling showed that each tick would be 10,000 cycles apart when only 520 cycles is needed for 19200 at 1MHz! :D

Edit:
Quote:
It also tells of the data corruption matter you mention regarding making CTS go false during the transmission of an already-started frame
It slipped my mind while typing, but the other (more major?) issue is that with TxEmpty always forced ON there's no way of testing if the other end is saying "WOAH!", so the work-around of monitoring CTS directly by connecting it to another pin that is testable.

_________________
--
JGH - http://mdfs.net


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

All times are UTC


Who is online

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