Saturday, November 17, 2012

Running Z80 in no-nothing mode

Well, it's time to run Z80 in do-nothing mode.
The great news (oh, well, maybe for someone that's really news) that NOP operator in Z80 is exactly FF [UPDATE: FF IS RST38!] since at least Intel i8080 times (4040? 4004? I do not know.).
It means that if we put FF on data bus via pull-up resistors- the CPU will execute NOP, then take the following address, execute NOP, etc, blinking LED on the address bus.
[UPD: It's all wrong. It will execute RST 38, but will blink, yeah. That's because it refreshes memory]
And here is idea.
What I changed:
1) they use 8 resistors from +5 to data bus. Actually, I used one - one side to +5, the other to shorded data bus.
2) they used some weird chip as clock source (what's this? 555 clone? to lazy to find it out), but I used... You know - ATmega8!

The photos: 1, 2

Continued under cut


Ну чо, самая тема запустить Z80 который будет делать нихуя. (кстати это - мое любимое занятие).
Для некоторых может и новость - но это для кого как - что команда Нихуя - NOP - еще со времен как миниум i8080 имеет код FF, за что большое спасибо компании Intel. [UPD: А аффтор-то лошок! FF - это RST 38] То есть если повесить легкий плюс на весь data bus - CPU будет перебирать адресной шиной. Куда я повесил светодиод.
[UPD: Боже, какой я кретин. Но моргать адресными шинами все равно будет - потому что будет рефрешить память]
Основная идея - тут
Разница:
1) у них 8 резюков, я на них сэкономил - повесил один от +5 на всю шину данных, ее замкнул нахуй
2) хрен поймет что у них там за чип в качестве тактового генератора, я, естественно, взял Atmega8.

А теперь - СИСЬКИ! фотки: 1, 2

I assume you have Atmega8 or smth like that on your's breadboard.
On the photo that's a 28 pin chip. It has 2 leds near it, one on leg 23 (PC0 port) via 1kohm resistor to +5, the other is just gnd-to-power via resistor, too.
It has resistor on reset leg 1 to +5. 10kohm, I suppose.
The white/grey cable is (usbasp) programmer. It connect via 10 pin standard connector to MOSI/RESET/SCK/MISO and provides power.
On my board you also see MAX232 (ADM232L) actually, surrounded by capacitors, not used while blinking Z80 bus, but connected to a standard atmega's legs 2/RXD & leg 3/TXD leading to DB9 RS232 socket, and yellow led - connected to address line (leg 30) of the Z80 via transistor.
The scheme of transistor: Z80 leg30 -[resistor 1kohm] - base of pnp transisor. Transistor emitter on gnd, collector to led, the other leg of led on +5.

You can also see an empty 28 pin socket and two red resistors with smth wht looks like a transistor. 20 pin socket will be used for flash ROM later, and the transistor is not a transistor at all but ds18s20 temperature sensor. I just made an thermometer on atmega8, if you are interested - it's here, but not going ds18s20 in Z80 project in the nearest future.

Z80 is connected the following way: leg 11 power, leg 29 gnd, data bus - 7-8-9-10-12-13-14 shorted and via the resistor (10k?) to +5 - YOU *MUST* INSTALL THE RESISTOR, leg 6 to atmega8's leg 23, +5 on 24,16,17,25, leg 30 as described.

The firmware of atmega follows, but it's very simple firmware.


Ну atmega8 у вас на макетке распаяна конечно, у меня это 28 ногий чип. Там 2 светодиода рядом, один на 23 ноге (порт PC0) через килоомный резистор на +5, второй - просто земля-резюк-led-+5.
На ноге 1 (reset) на +5 висит резистор. Наверное 10k.
Серобелый кабель это программатор avrки (usbasp). Там 10 пиновый коннектор на MOSI/RESET/SCK/MISO и с него идет +5 и gnd.
Также на плате у меня видно MAX232 (на самом деле ADM232L, но не ссуть), окруженная кондерами, но в данный момент нас это не интересует. Ну там ноги 2 и 3 atmega8 идут на MAX232, к нему прихерачен ком-порт, а дальше торчит желтый светодиод, который влючен так: Z80 нога30 -[резюк 1kohm] - база 3107. Его эмиттер на земле, коллектор-LED-+5.

Ну там еще кровать на 28 пин неюзанная пока и 2 красных резюка с чем-то похожим на транзюк, хотя это нифига не транзюк, а ds18s20 температурный сенсор. Я его в обозримом будущем в Z80 сувать не собирался, я просто собирал на atmega термометр - получилось такое, кстати.

Z80 соединен так: нога 11 +5, 29 - земля, датабас вся закорочена, нахуй, как я и обещал, от нее торчит резюк (тоже наверное 10k) на +5 и ОН ПРАВДА НУЖЕН БЕЗ НЕГО НИЧЕГО РАБОТАТЬ НЕ БУДЕТ, 6 нога на atmegaвскую 23, +5 на 24,16,17,25,про 30ую я уже сказал.

Фирмваря под atmega, но как бы это совсем простенько.

/*
File: main.c
Version: 1.0.0
Date: May. 12, 2006

AVR Tutorial #1 - Toggle and LED on PC0

Schematic available at http://www.micahcarrick.com.

****************************************************************************
Copyright (C) 2006 Micah Carrick

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#define F_CPU 1000000UL /* 1 MHz Internal Oscillator */

#include <avr/io.h>
#include <inttypes.h>
#include <util/delay.h>

/* function for long delay */
void delay_ms(uint16_t ms) {
while ( ms )
{
_delay_ms(1);
ms--;
}
}

int main (void)
{
/* PC0 is digital output */
DDRC = _BV (PC0);

/* loop forever */
while (1)
{
/* clear PC0 on PORTC (digital high) and delay for 1 Second */
PORTC &= ~_BV(PC0);
delay_ms(200);
PORTC |= _BV(PC0);
delay_ms(200);
}
}

No comments:

Post a Comment