ATtiny13 for clock and resets?

Let's talk about anything related to the 6502 microprocessor.
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

ATtiny13 for clock and resets?

Post by cbmeeks »

I've been using the DS1813 in some of my circuits for resetting the 65C02. Works great but they are a little pricey at around $2.43 each.

I'm also going to start learning the NXP SC28 UART which, IIRC, has an active-high reset (vs. active-low for 6502). Just use an inverter...no problem.

So instead of the DS1813 and an inverter, why not use an ATtiny13 for around $0.85? It has 6 I/O and can run 20 MHz (IIRC).

Could the ATtiny13 do the following?:

1) Monitor (and de-bounce) the reset button (1 I/O)
2) Hold 6502 reset high when button not pressed (1 I/O)
3) Hold NXP reset low when button not pressed (1 I/O)
4) Provide 1 MHz clock (1 I/O) for devices

That's 4 I/O lines.

Now, I'm not sure if it can really push a 1 MHz square wave externally. Of course, this limits has fast your machine can run but I'm building a 1 MHz machine anyway.

Even if I didn't use it for the clock, seems like a no-brainer for the reset lines.

Thoughts?


ATtiny13

https://www.mouser.com/ProductDetail/Mi ... NJHUXxU%3d

Datasheet

https://www.mouser.com/datasheet/2/268/ ... 315482.pdf
Cat; the other white meat.
Martin A
Posts: 197
Joined: 02 Jan 2016

Re: ATtiny13 for clock and resets?

Post by Martin A »

Another option for reset supervisor for less than the cost of the ATTiny13 is the TL7705.

It's got active high and active low resets. It's available in hobby friendly DIP packaging too.

I've used it with the 65C02 and 82C55 PPI.
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: ATtiny13 for clock and resets?

Post by cbmeeks »

Ah, not a bad idea. Haven't seen those. They are a little cheaper.
Cat; the other white meat.
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Re: ATtiny13 for clock and resets?

Post by BitWise »

The internal oscillator runs a funny speed (4.8MHz or 9.6MHz) which might be awkward to scale down to 1MHz. I've never used Atmel chips directly.

I got a PIC16F18313 doing the same kind of thing a while back.
https://github.com/andrew-jacobs/hz-maker
The PIC has a 8MHz clock which can be divide down into 1, 2, 4 or 8Mhz output. It has a numerically controlled oscillator that is used to generate a 1.8432MHz signal for a 6551 ACIA but could produce other baud rate frequencies.
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
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: ATtiny13 for clock and resets?

Post by cbmeeks »

I believe the Atmel chips can take an external clock up to 20MHz and then divide that down more evenly.

Ah, that's a good point about the ACIA clock too. For my UART, I think I need another clock of 3.6864 MHz. So perhaps I skip the ATtiny for clock generation, use a 3.6864 MHz crystal and just divide by 2 for the CPU clock. A little faster than 1 MHz but it would be in lock-step with the UART.

Not sure how important that is, however.

1 MHz makes the math easy. :-)
Cat; the other white meat.
User avatar
Druzyek
Posts: 367
Joined: 12 May 2014
Contact:

Re: ATtiny13 for clock and resets?

Post by Druzyek »

I have been thinking about something very similar. Those Atmel parts are very attractive since they work at up to 5v and cost around a dollar.

Looking at the datasheet, I did not find an option to reroute the system clock to one of the pins, so you would have to flip the clock pin yourself with code. With 9.6 MHz as the internal oscillator frequency, so you would have 9-10 cycles to flip the pin and jump back to the beginning of the flip routine. This might just be doable since the AVRs are supposed to have mostly single cycle instructions. I have never tried, though, so I'm not sure. If you want the 20 MHz frequency the datasheet mentions, you need to supply that signal to the chip yourself, since it doesn't have the circuitry to support a crystal.

I have been looking at another chip in that line called the ATtiny2313A, which is $1.36 and comes in DIP20:

http://ww1.microchip.com/downloads/en/D ... oc8246.pdf

On page 27 you can see that it has an 8 MHz internal oscillator that can be divided by 8, which gives you 1 MHz. Page 32 shows that you can output this signal on a pin, so you don't have to execute any code to generate the clock. It can run from an external clock like the ATtiny13 or from a crystal connected directly to the chip. This would let you generate any clock up to 20 MHz depending on the crystal you use if you want to build a faster 6502 system.

Another option with similar capability is the ATmega48 for $1.79 in DIP28:

https://www.mouser.com/datasheet/2/268/ ... 315337.pdf

You could replace a of functionality in the VIA and other chips since these have SPI/I2C/PWN/timers/ADC/USART built in.
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: ATtiny13 for clock and resets?

Post by floobydust »

Martin A wrote:
Another option for reset supervisor for less than the cost of the ATTiny13 is the TL7705.

It's got active high and active low resets. It's available in hobby friendly DIP packaging too.

I've used it with the 65C02 and 82C55 PPI.
I also used the TL7705B in my recent C02 Pocket SBC. There are a small number of additional components, resistors/capacitors required but it's been a very good choice, as I also used a NXP UART, hence the positive going Reset signal requirement. Attached is a partial schematic showing the TL7705B Reset and a DS-1813 NMI Panic.
TL7705B_Circuit.jpg
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: ATtiny13 for clock and resets?

Post by BigDumbDinosaur »

cbmeeks wrote:
For my UART, I think I need another clock of 3.6864 MHz.
You do.
Quote:
So perhaps I skip the ATtiny for clock generation, use a 3.6864 MHz crystal and just divide by 2 for the CPU clock. A little faster than 1 MHz but it would be in lock-step with the UART.

Not sure how important that is, however.
NXP UARTs operate asynchronously to the MPU and only know about the 3.6864 MHz clock. Hence the MPU's Ø2 rate can be anything you want.

Incidentally, I recommend you use a can oscillator, not a crystal, to generate your clocks.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: ATtiny13 for clock and resets?

Post by whartung »

There's just something about using a micro controller made with ~50,000 transistors to run as a clock and reset circuit for a 3500 transistor CPU.
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: ATtiny13 for clock and resets?

Post by cbmeeks »

BigDumbDinosaur wrote:
Incidentally, I recommend you use a can oscillator, not a crystal, to generate your clocks.
Yeah, that's actually what I meant. Just came out as crystal. :-)

whartung wrote:
There's just something about using a micro controller made with ~50,000 transistors to run as a clock and reset circuit for a 3500 transistor CPU.
Then there's that. lol.
That thought hasn't escaped me. However, I guess the same could be said about using any PLD's as well. Especially the larger ones.
Cat; the other white meat.
LIV2
Posts: 173
Joined: 12 Feb 2014
Location: Sweden

Re: ATtiny13 for clock and resets?

Post by LIV2 »

That's not a bad idea, I wish I'd thought of it
My computer has an attiny861a working as the keyboard controller, with one spare pin. I could've just used it as my reset controller instead of the 1813
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: ATtiny13 for clock and resets?

Post by whartung »

cbmeeks wrote:
Then there's that. lol.
That thought hasn't escaped me. However, I guess the same could be said about using any PLD's as well. Especially the larger ones.
Yea, it's just funny.

Just the state of the world today.

I was reading on another forum about a guy who made something that plugged in to his cars CAN bus.

On the car, if you reach in the door handle, its supposed to unlock automatically. Sometimes it takes a few tries.

He made something that would detect the door handle activity, and if it didn't see the "unlock door" request "quickly", it would send the door request again.

Now, I'm sure its more sophisticated than monitor the CAN traffic for a "2" and then sending a "3" after a timer, but it's not much more than that.

But the thing is he's using a Raspberry Pi Zero and a CAN bus controller. Basically ~$10 in hardware.

And now you have a machine with a GHz processor and hundreds of MBs of RAM....listening for a "2" so it can send a "3".

Just like Marvin the robot in Hitchhikers Guide.
Quote:
“Here I am, brain the size of a planet and they ask me to take you down to the bridge. Call that job satisfaction? ‘Cos I don’t.” –Marvin
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: ATtiny13 for clock and resets?

Post by cbmeeks »

LIV2 wrote:
My computer has an attiny861a working as the keyboard controller, with one spare pin. I could've just used it as my reset controller instead of the 1813
Yep, I have absolutely convinced myself to use some micro-controller for the reset logic. Then the question becomes...ATtiny for just resets or go all-out and put an Arduino compatible circuit onboard (minus the headers) so that I can get some easy SD/FAT libraries, easy EEPROM access, etc. :-D

whartung wrote:
I was reading on another forum about a guy who made something that plugged in to his cars CAN bus.

On the car, if you reach in the door handle, its supposed to unlock automatically. Sometimes it takes a few tries.

He made something that would detect the door handle activity, and if it didn't see the "unlock door" request "quickly", it would send the door request again.

Now, I'm sure its more sophisticated than monitor the CAN traffic for a "2" and then sending a "3" after a timer, but it's not much more than that.

But the thing is he's using a Raspberry Pi Zero and a CAN bus controller. Basically ~$10 in hardware.

And now you have a machine with a GHz processor and hundreds of MBs of RAM....listening for a "2" so it can send a "3".
I feel the same way. But like you said, that's where the "action" is these days. I've been blasted in other forums because I said I was tired of hearing about RPi projects. Now don't get me wrong, RPi is a great ecosystem, great device, etc. I'm just tired of hearing it over and over. lol.
Cat; the other white meat.
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: ATtiny13 for clock and resets?

Post by Dr Jefyll »

whartung wrote:
I was reading on another forum about a guy who made something that plugged in to his cars CAN bus.
Bill, can you tell me please, what forum was that?

I PM'd you Monday with this question but for some reason the PM hasn't yet been read.

TIA,
Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
unclouded
Posts: 81
Joined: 24 Feb 2015

Re: ATtiny13 for clock and resets?

Post by unclouded »

cbmeeks wrote:
Now, I'm not sure if it can really push a 1 MHz square wave externally. Of course, this limits has fast your machine can run but I'm building a 1 MHz machine anyway.
It should be possible. I used C not assembler and used a software loop to manage PHI2 for simulating bus devices and got around 250 kHz from memory.

As others have said, many AVR devices other than the ATtiny13 can get a precise clock with only a crystal and a couple of capacitors such as in this board:

https://github.com/neilstockbridge/6502 ... /master/R1

The ATtiny85 is another part also in DIP8 but with more program memory and peripherals and can use an external crystal (at the expense of losing two pins).
whartung wrote:
There's just something about using a micro controller made with ~50,000 transistors to run as a clock and reset circuit for a 3500 transistor CPU.
I started with AVRs in my 6502 system but then replaced them with FPGAs and finally period-correct logic in pursuit of purity. I think they're all different adventures though.
Post Reply