Skip to content

A Better Reset Circuit

October 22, 2015

A clever person suggested that i could simplify my crazy elaboate reset circuit with a maxim ds1232 part. That’s a thing with a programmable length power on reset and button debouncing. That’s an excellent idea and it made me realize that i could do it with an 8 pin attiny85 which could also generate a 1khz interrupt for Josh’s monitor.
The breadboard does not look all that much better but it’s easier for me to understand and getting the khz clock is a great bonus. Being able to have a millis() equivalent will be excellent.
15-10-22 breadboard
The Schematic, again, does not look all that much simpler but remember that i now have the millisecond clock built in. I could have gotten rid of the diode on the /int line by having the avr mimic an open drain output but that seems tricky.
15-10-22 schematic

Programming the attiny would not be hard except that I do it so seldom I can’t remember the details. The avr studio screen shot below shows the code and programming dialogue. The actual c code is below that.
15-10-22 programming

//Oct 21 2015 attiny85 pgm to power on reset Z80 then provide 1 khz clock
//to program with pololu programmer
//-choose AVRISP (near bottom of programmer list)
//-can leave port at auto
#include <avr/io.h>
#define F_CPU 8000000UL // 8 MHz
#include <util/delay.h>
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#define khz		4	//my +1khz clock output on PB4(IC pin 3) to /INT
#define nkhz	5	//my -1khz clock output on PB2(IC pin 7) to IN6
#define rst 	3	//reset signal on PB3(IC pin 2)

int main(void)
{
	sbi(DDRB,rst);	//z80 reset pin as output
	sbi(DDRB,khz);	//khz clock pin as output
	sbi(DDRB,nkhz);	//nkhz inverted clock pin as output

	cbi (PORTB,rst);	//drive z80 into reset
	_delay_ms(100);	//to clear startup jitters
	sbi (PORTB,rst);	//take z80 out of reset

	while(1){		//loop
		sbi(PORTB,khz);cbi(PORTB,nkhz);
		_delay_us(500);	//half of 1khz cycle
		cbi(PORTB,khz);sbi(PORTB,nkhz);
		_delay_us(500);	//half of 1khz cycle
	}
	return 1;
}

I created a new project called zmcmule specifying attiny85 and avrgcc, that opened a window for zmcmule.c which i put the code into. build/build generated the hex file zmcmule.hex in documents/default. In the connection dialog i specify avrisp and auto and let it find the programmer on com4. the attiny showed up as signature xx xx xx and fuses xx xx xx indicating an 8mhz clock based on the internal oscillator. I was able to use the attiny programming jig that i developed a while ago and provide power from the programmer’s vbus pin. It was relatively straightforward but took a couple of hours because i haven’t done it for a while.

Now, I just have to modify josh’s monitor to take advantage of the clock and leave the rest of the ports alone and…

Advertisements

From → Olduino/Z

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: