AVR as UART/ACIA IC
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: AVR as UART/ACIA IC
cbscpe wrote:
All these wait state generators generate a fixed predicted number of wait states. Has anyone a more bus related wait-state generator? I mean something like used in typical bus protocols where the CPU is always halted until a ACK signal is generated by the selected device (IO, Memory, ROM etc). Preferably the ACK should be a edge sensitive signal. E.g. in a PDP-11 system the CPU always stalled when performing a read or write until a CONT signal was asserted on the bus. Even Memory had to create the CONT signal.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: AVR as UART/ACIA IC
> Why would you need something like that?
Surely you'd need this in any system which a peripheral unable to clock at full speed. That's pretty common - but the usual workaround is to clock everything at the slowest speed.
Surely you'd need this in any system which a peripheral unable to clock at full speed. That's pretty common - but the usual workaround is to clock everything at the slowest speed.
Re: AVR as UART/ACIA IC
Exactly I have the requirement that I have peripherals that do not responds with a known speed, but they known when they have finished the transfer. I want to avoid to use a VIA as these peripherals have a normal bus interface. On the other hand I want the system to run at maximum speed when it comes to memory access or when peripherals are accessed that support high clock rates. Clocking everything at the lowest common speed is definitively what I want.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: AVR as UART/ACIA IC
Quote:
Using a VIA to interface with the AVR is possible but very slow and it uses a lot of pins. Also it is not trivial to build a bidirectional bus between the AVR and the VIA, as each side decides on the direction of the IO pins. Instead of a VIA I would use something like the 74HCT652.
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?
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: AVR as UART/ACIA IC
cbscpe wrote:
Exactly I have the requirement that I have peripherals that do not responds with a known speed, but they known when they have finished the transfer.
Last edited by BigDumbDinosaur on Fri Sep 18, 2015 3:30 am, edited 1 time in total.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: AVR as UART/ACIA IC
Let's say you want to interface a fast running 65C02 with all the IO features of a AVR (using the AVR as peripheral, not only the USART). So as soon the IO selects the AVR I need to assert RDY (=low) and wait until the AVR did what he should do. Typically it would just pass through the byte from/to the selected internal register to/from the 65C02 data bus. When he did it's job the AVR needs to tell the logic that keeps RDY asserted that it's done. You could use a pulse generated by the AVR to clear the RDY status. But the shortest pulse you can generate is 50ns with an AVR running at 20MHz. But you must make sure that the pulse is finished before a low-to-high transition of PHI2 because when you de-assert RDY before PHI2 transitions from high-to-low this low-to-high transition could be another access to the AVR and then the logic that asserts RDY must not be disturbed by a still lasting clear pulse from the AVR. Else the 65C02 will run over this cycle without that the AVR would have don it's job. This limits the clock speed of the 65C02 to approx 10MHz. But I want go much faster. I could somewhat alleviate the requirement by saying that there are no 2 consecutive cycles that access the AVR, but then I loose the option to provide instructions from the AVR to the 65C02. You might say, that this would be very slow, but on the other hand, if I use this only to download a ROM image, speed for this phase does not matter.
The reason I would like to do so is that with that I only need a 65C02, a fast RAM, some glue and a AVR and would have a very small system with a lot of IO features.
What I would need is equivalent of a D-type FF with the IO select connected to the D input and PHI2 connected to clock, this would provide the logic to assert RDY when required, and then I would need a edge triggered input to de-assert RDY again and not the typical level triggered clear/set inputs of a 74xx74.
The reason I would like to do so is that with that I only need a 65C02, a fast RAM, some glue and a AVR and would have a very small system with a lot of IO features.
What I would need is equivalent of a D-type FF with the IO select connected to the D input and PHI2 connected to clock, this would provide the logic to assert RDY when required, and then I would need a edge triggered input to de-assert RDY again and not the typical level triggered clear/set inputs of a 74xx74.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: AVR as UART/ACIA IC
The many wait states that would be needed in any I/O intensive situation sound like quite a performance killer. To read a status register or port for example requires the microcontroller to go through its interrupt sequence (which someone said was 7 cycles on the AVR), then negate RDY, decode the "register select" as an instruction, fetch the contents of the desired register, and put them on the 6502's bus, bring RDY back up (assert it), then do the return-from-interrupt before it's ready to start the process over again. R-M-W instructions might be totally out of the question. Doing the other things on a polled basis (to avoid the interrupt overhead) may not allow doing other things the AVR needs to do. Going with dedicated parallel I/O ICs of even other families sounds like a much better solution. I believe BDD likes the 28L92.
BTW, RDY is a positive-logic signal. Pulling it down constitutes negating it, meaning "No, I'm not ready to move on. I need more time." High (asserting it) means, "Yes. Ready. Go."
BTW, RDY is a positive-logic signal. Pulling it down constitutes negating it, meaning "No, I'm not ready to move on. I need more time." High (asserting it) means, "Yes. Ready. Go."
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: AVR as UART/ACIA IC
cbscpe wrote:
You could use a pulse generated by the AVR to clear the RDY status. But the shortest pulse you can generate is 50ns with an AVR running at 20MHz.
GARTHWILSON wrote:
BTW, RDY is a positive-logic signal. Pulling it down constitutes negating it, meaning "No, I'm not ready to move on. I need more time." High (asserting it) means, "Yes. Ready. Go."
- asserting a signal called READY means, "I am ready"
- negating a signal called READY means, "I am not ready"
Active-high or active-low is a secondary detail, and it doesn't change the rule. "Assert means do what the English word says." At least that's how I keep myself from muddling things up!
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: AVR as UART/ACIA IC
GARTHWILSON wrote:
Going with dedicated parallel I/O ICs of even other families sounds like a much better solution. I believe BDD likes the 28L92.
Last edited by BigDumbDinosaur on Fri Sep 18, 2015 3:43 am, edited 1 time in total.
x86? We ain't got no x86. We don't NEED no stinking x86!
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: AVR as UART/ACIA IC
Dr Jefyll wrote:
I modified one of my other wait-state diagrams, Peter -- see what you think of this (below).
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: AVR as UART/ACIA IC
GARTHWILSON wrote:
The many wait states that would be needed in any I/O intensive situation sound like quite a performance killer.
Code: Select all
ldi zh, high(iotable)
cbi PIND, DONE ; Prepare for next IO
sbic PIND, CS
rjmp housekeeping ; If you want something be done, else it's just jumping to the cbi
in zl, PINA ; Assume we read A0..A6 and RW with this
ijmp
align 8
iotable:
rjmp readioreg
.
.
.
rjmp writeioreg
readioreg:
would take about 20 AVR cycles. Michael's 3-chip design uses 16 AVR cycles to do everything a 65C02 expects to happen in one PHI2 cycle. When you think about the number of IO access a IO routine does in relation to the code it must execute (LDA ioaddress and a Bxx LOOP) the relative performance degradation is not that that important. Imagine that a 20MHz AVR would only throttle systems running at more than 1MHz and only during AVR IO cycles. In a typical application only a few cycles. If you are doing some real-time stuff and require a lot of IO cycles due to your system requirements, then this is definitively not the solution. So whether the performance penalty is relevant or not depends a lot on your application.
GARTHWILSON wrote:
BTW, RDY is a positive-logic signal. Pulling it down constitutes negating it, meaning "No, I'm not ready to move on. I need more time." High (asserting it) means, "Yes. Ready. Go."
Dr Jefyll wrote:
I modified one of my other wait-state diagrams, Peter -- see what you think of this (below).
BigDumbDinosaur wrote:
The reason devices such as UARTs exist is they do very efficiently in hardware what a microcontroller less efficiently and more slowly in software.
BigDumbDinosaur wrote:
The only thing I'd add to that circuit is a small Schottky diode in between the flop's Q output and the MPU's RDY pin, as RDY is bi-directional.
Re: AVR as UART/ACIA IC
cbscpe wrote:
Jeff, thanks a lot, looks promising. Just that with J=H and /K=L the ff will toggle, so I will probably add another flip-flop between DONE and J to limit the DONE=High time to one PHI2 cycle.
Another suggestion, just to stir the pot...
- Attachments
-
- 74hc646.pdf
- (91.88 KiB) Downloaded 434 times
Last edited by Dr Jefyll on Fri Sep 18, 2015 7:30 am, edited 1 time in total.
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: AVR as UART/ACIA IC
What we need is something like the WSI (Waferscale Integration, Inc.) WSD3XX family. I remembered this in a 1992 WSI data book I have; but looking them up online, it looks like they were bought out by ST Microelectronics (formerly SGS Thomson), who later dropped the line. WSI made these ICs that had RAM, ROM, and I/O all in one IC, to connect to a microprocessor. I suppose that idea went out as microcontrollers took over. They were definitely not ubiquitous yet in 1992, and the options were quite limited, especially if you couldn't afford to get masks made for your program.
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?
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
Re: AVR as UART/ACIA IC
Several PICs have an 8-bit 'parallel slave port' (PSP) that interfaces with a microprocessor bus (e.g. with /CS, /RD, /WR lines) but on the 16F and 18F devices you only get one addressable location.
Some of the 3V3 16-bit PICs have a 'parallel master port' (PMP) with either a legacy PSP mode with optional 4 byte deep fifos (for both read and write) or a single an enhanced PSP mode that adds two address lines so you can have four memory locations.
In your code you latch the state of each location and an interrupt occurs when either the value has been read or overwritten by the bus owner. You must code the interrupt processor to process the read/write and update the latch before the next access. On 18F and PIC24s you can prioritize interrupts to make sure this is as fast as possible.
I've been meaning to try using them in a circuit. Only having a single location makes the 16F/18F PSP seem a bit limited but you could use a VIA driving other PIC input pins to indicate if the access is for data or control operation and check in the interrupt handler.
Some of the 3V3 16-bit PICs have a 'parallel master port' (PMP) with either a legacy PSP mode with optional 4 byte deep fifos (for both read and write) or a single an enhanced PSP mode that adds two address lines so you can have four memory locations.
In your code you latch the state of each location and an interrupt occurs when either the value has been read or overwritten by the bus owner. You must code the interrupt processor to process the read/write and update the latch before the next access. On 18F and PIC24s you can prioritize interrupts to make sure this is as fast as possible.
I've been meaning to try using them in a circuit. Only having a single location makes the 16F/18F PSP seem a bit limited but you could use a VIA driving other PIC input pins to indicate if the access is for data or control operation and check in the interrupt handler.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
Re: AVR as UART/ACIA IC
Dr Jefyll wrote:
Another suggestion, just to stir the pot...
The need for wait-states -- and some of the performance compromises mentioned -- would disappear if you used a registered bus transceiver (such as 'hc646) as the connection point between the 65xx and the AVR. Each processor would be able to leave a one-byte message for the other -- then continue with its own business immediately.
BitWise wrote:
Several PICs have an 8-bit 'parallel slave port' (PSP) that interfaces with a microprocessor bus (e.g. with /CS, /RD, /WR lines) but on the 16F and 18F devices you only get one addressable location.