Import code from old repository from 2018

Old repository: https://github.com/binaryDiv/z80_computer
This commit is contained in:
Lexi / Zoe 2021-04-03 17:21:59 +02:00
parent 536e557eea
commit 8c7b62dc2d
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
19 changed files with 3076 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# C code: object files etc.
*.o
*.obj
*.elf
*.hex
*.gch
*.pch
# vim swap files
.*.swp

44
firmware_src/BitIO.h Normal file
View File

@ -0,0 +1,44 @@
/**
* BitIO.h
* @author Andi Dittrich <http://andidittrich.de>
* @version 1.0
* @license MIT Style X11 License
*/
#include <inttypes.h>
#include <stdbool.h>
#ifndef BITIO_H_
#define BITIO_H_
// set bit
static inline void BIT_SET(volatile uint8_t *target, uint8_t bit) __attribute__((always_inline));
static inline void BIT_SET(volatile uint8_t *target, uint8_t bit){
*target |= (1<<bit);
};
// set clear
static inline void BIT_CLEAR(volatile uint8_t *target, uint8_t bit) __attribute__((always_inline));
static inline void BIT_CLEAR(volatile uint8_t *target, uint8_t bit){
*target &= ~(1<<bit);
};
// bit toogle
static inline void BIT_TOGGLE(volatile uint8_t *target, uint8_t bit) __attribute__((always_inline));
static inline void BIT_TOGGLE(volatile uint8_t *target, uint8_t bit){
*target ^= (1<<bit);
};
// set bit by boolean
static inline void BIT_BOOL_SET(volatile uint8_t *target, uint8_t bit, bool enable) __attribute__((always_inline));
static inline void BIT_BOOL_SET(volatile uint8_t *target, uint8_t bit, bool enable){
if (enable){
BIT_SET(target, bit);
}else{
BIT_CLEAR(target, bit);
}
};
#endif /* BITIO_H_ */

75
firmware_src/Makefile Normal file
View File

@ -0,0 +1,75 @@
################
# CONFIGURATION
################
# Compiler and tools
CC = avr-gcc
OBJCOPY = avr-objcopy
# Compiler and linker flags
CFLAGS = -Wall -std=c11 -Os
LDFLAGS =
# Target platform and programmer
GCC_MCU = atmega16a
AVRDUDE_PARTNO = m16
AVRDUDE_PROGRAMMER = usbtiny
# Make target and object files
TARGET = eepprog
OBJECTS = main.o uart.o eeprom.o protocol.o
HEADERS = config.h BitIO.h uart.h eeprom.h protocol.h
# Default target (build hex file)
all: hex
################
# BUILD TARGETS
################
# Shortcuts for build targets
hex: $(TARGET).hex
elf: $(TARGET).elf
# Convert elf binary to ihex format
$(TARGET).hex: $(TARGET).elf
$(OBJCOPY) -O ihex $(TARGET).elf $(TARGET).hex
# Elf binary
$(TARGET).elf: $(OBJECTS)
$(CC) -mmcu=$(GCC_MCU) $(LDFLAGS) -o $(TARGET).elf $(OBJECTS)
# Object files
%.o: %.c $(HEADERS)
$(CC) -mmcu=$(GCC_MCU) $(CFLAGS) -c -o $@ $<
##############
# PROGRAMMING
##############
# Program controller
program: writeflash
writeflash: $(TARGET).hex
sudo avrdude -p $(AVRDUDE_PARTNO) -c $(AVRDUDE_PROGRAMMER) -U flash:w:$(TARGET).hex
readfuse:
sudo avrdude -p $(AVRDUDE_PARTNO) -c $(AVRDUDE_PROGRAMMER) -U lfuse:r:m -U hfuse:r:m
writefuse:
sudo avrdude -p $(AVRDUDE_PARTNO) -c $(AVRDUDE_PROGRAMMER) -U lfuse:w:0xef:m -U hfuse:w:0xd9:m
################
# OTHER TARGETS
################
# Clean generated files
clean:
rm -f $(OBJECTS) $(TARGET).elf $(TARGET).hex
.PHONY: all hex elf program writeflash clean

12
firmware_src/config.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef CONFIG_H_
#define CONFIG_H_
// Set CPU rate
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
// Set UART Baud rate
#define BAUD 9600UL
#endif /* CONFIG_H_ */

117
firmware_src/eeprom.c Normal file
View File

@ -0,0 +1,117 @@
#include "config.h"
#include "eeprom.h"
#include <avr/io.h>
#include <util/delay.h>
#include "BitIO.h"
// Initialize EEPROM
void eepromInit() {
// Set initial value for control port (all disabled -- INVERTED VALUES, ~CE, ~OE, ~WE)
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_CE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_OE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_WE);
// Set data direction register for control port
EEP_CTRL_DDR |= (1 << EEP_CTRL_BIT_CE)
| (1 << EEP_CTRL_BIT_OE)
| (1 << EEP_CTRL_BIT_WE);
// Set initial value for address (0x0000)
EEP_ADDR_LOW_PORT = 0x00;
EEP_ADDR_HIGH_PORT = 0x00;
// Set data direction register for address ports
EEP_ADDR_LOW_DDR = 0xFF;
EEP_ADDR_HIGH_DDR = 0xFF;
// Set data direction register and initial value for IO port (initialize in reading mode)
EEP_DATA_PORT = 0x00;
EEP_DATA_DDR = 0x00;
}
// Enable read mode (set data direction registers and enable output)
void eepromSetReadMode() {
// Reset control bits (shouldn't be necessary, but let's be safe)
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_CE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_OE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_WE);
// Set data pins as input, reset PORT to disable pullups
EEP_DATA_PORT = 0x00;
EEP_DATA_DDR = 0x00;
}
// Enable write mode (set data direction registers)
void eepromSetWriteMode() {
// Reset control bits (shouldn't be necessary, but let's be safe)
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_CE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_OE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_WE);
// Set data pins as output, reset data port
EEP_DATA_PORT = 0x00;
EEP_DATA_DDR = 0xFF;
}
// Set address
static inline void eepromSetAddress(address_t address) {
// Set low and high address bytes
// (We actually only have 15 bit, the 16th will just be ignored)
EEP_ADDR_LOW_PORT = address & 0xFF;
EEP_ADDR_HIGH_PORT = address >> 8;
}
// Read byte (assumes we're in read mode)
uint8_t eepromReadByte(address_t address) {
// Assume we're in read mode
// Set address
eepromSetAddress(address);
// Latch address
BIT_CLEAR(&EEP_CTRL_PORT, EEP_CTRL_BIT_CE);
BIT_CLEAR(&EEP_CTRL_PORT, EEP_CTRL_BIT_OE);
// 1 tick = 62.5 ns, EEPROM access time is 150 ns.
// 2 NOPs seem to be sufficient, but let's be sure.
_NOP();
_NOP();
_NOP();
// Get data
uint8_t byte = EEP_DATA_PIN;
// Reset ~OE, ~CE
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_OE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_CE);
// Read and return data byte
return byte;
}
// Write byte (assumes we're in write mode)
void eepromWriteByte(address_t address, uint8_t data) {
// Assume we're in write mode
// Set address
eepromSetAddress(address);
// Falling edge: latch address
BIT_CLEAR(&EEP_CTRL_PORT, EEP_CTRL_BIT_CE);
BIT_CLEAR(&EEP_CTRL_PORT, EEP_CTRL_BIT_WE);
// Set data byte
EEP_DATA_PORT = data;
// Data setup time (50ns)
_NOP();
// Rising edge: latch data, start write cycle
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_WE);
BIT_SET(&EEP_CTRL_PORT, EEP_CTRL_BIT_CE);
// Write pulse width high (50ns)
_NOP();
}

48
firmware_src/eeprom.h Normal file
View File

@ -0,0 +1,48 @@
#ifndef EEPROM_H_
#define EEPROM_H_
#include "config.h"
#include <avr/io.h>
// Define macro for NOP instruction
#define _NOP() __asm__ __volatile__ ("nop");
// Define type for (to be shifted) addresses
typedef uint16_t address_t;
// Define address length
// TODO 15 or 16?
#define ADDRESS_LENGTH 15
// Macros for IO pins
#define EEP_ADDR_LOW_PORT PORTC
#define EEP_ADDR_LOW_DDR DDRC
#define EEP_ADDR_HIGH_PORT PORTB
#define EEP_ADDR_HIGH_DDR DDRB
#define EEP_DATA_PORT PORTA
#define EEP_DATA_PIN PINA
#define EEP_DATA_DDR DDRA
#define EEP_CTRL_PORT PORTD
#define EEP_CTRL_DDR DDRD
#define EEP_CTRL_BIT_CE PD2
#define EEP_CTRL_BIT_OE PD3
#define EEP_CTRL_BIT_WE PD4
// Initialize EEPROM
void eepromInit();
// Enable read mode (set data direction registers and enable output)
void eepromSetReadMode();
// Enable write mode (set data direction registers)
void eepromSetWriteMode();
// Read byte (assumes we're in read mode)
uint8_t eepromReadByte(address_t address);
// Write byte (assumes we're in write mode)
void eepromWriteByte(address_t address, uint8_t data);
#endif /* EEPROM_H_ */

24
firmware_src/main.c Normal file
View File

@ -0,0 +1,24 @@
#include "config.h"
#include "uart.h"
#include "eeprom.h"
#include "protocol.h"
#include <util/delay.h>
int main(void) {
// Init components (UART, EEPROM, ...)
uartInit();
eepromInit();
// Initial pause (EEPROM needs 5ms startup time)
_delay_ms(100);
// Write initial message via UART
uartPutString("INFO -- EEPROM programmer by binaryDiv\r\n");
while(1) {
// Run main loop endlessly
protocolMainLoop();
}
}

142
firmware_src/protocol.c Normal file
View File

@ -0,0 +1,142 @@
#include "config.h"
#include "protocol.h"
#include "uart.h"
#include "eeprom.h"
#include <string.h>
#include <stdlib.h>
#include <util/delay.h>
// Splits a command "CMD ARGS" to two strings "CMD" and "ARGS". Returns pointer
// to "ARGS" or NULL if no arguments were found. Changes the input string!
char* tokenizeCommand(char* cmd) {
if (cmd == NULL) {
return NULL;
}
// Search for a space character
for (char* p = cmd; *p != '\0'; p++) {
if (*p == ' ') {
// Split strings by replacing the space by \0, then return pointer
// to command arguments
*p++ = '\0';
return p;
}
}
// No space character found: command has no arguments, return NULL
return NULL;
}
// Reads, parses and executes next command
void parseNextCommand() {
const int bufferLength = 80;
char buffer[bufferLength];
// Read next command
int readChars = uartGetLine(buffer, bufferLength);
// Check if line is non-empty and has been read completely
if (readChars == 0) {
return;
}
else if (readChars >= bufferLength-1) {
// Reading was aborted after bufferLength-1 characters to prevent
// buffer overflow.
// TODO Actually this isn't quite correct: if exactly bufferLen-1
// characters have been read including the \n, this could be
// true as well... test this?
uartPutString("ERROR buffer overflow while reading line\r\n");
return;
}
// Tokenize command
char* cmd = buffer;
char* args = tokenizeCommand(cmd);
// Parse command
if (strcmp(cmd, "HELLO") == 0) {
// HELLO command: initializes connection
uartPutString("OHAI\r\n");
}
else if (strcmp(cmd, "READ") == 0) {
// READ command: takes a hex address or address range as argument,
// reads data and returns them in hexadecimal ASCII format.
// Check if arguments exist
if (args == NULL) {
uartPutString("ERROR READ needs an address\r\n");
return;
}
// Parse address(es)
// TODO
uartPutString(args);
// Read...
// TODO
}
else if (strcmp(cmd, "TESTREAD") == 0) {
// TESTREAD command: for testing purposes, reads a few bytes and
// returns them in a human readable format.
uint8_t byte;
char outBuffer[20];
eepromSetReadMode();
for (int i = 0x00; i < 0x20; i++) {
itoa(i, outBuffer, 16);
uartPutString("TESTREAD 0x");
uartPutString(outBuffer);
uartPutString(": ");
byte = eepromReadByte(i);
itoa(byte, outBuffer, 16);
uartPutChar(byte);
uartPutString(" (0x");
uartPutString(outBuffer);
uartPutString(")\r\n");
}
}
else if (strcmp(cmd, "TESTWRITE") == 0) {
// TESTWRITE command: for testing purposes, writes a few bytes
char str[] = "Ohai world";
address_t addr = 0x00;
char* writeStr = str;
if (args != NULL) {
writeStr = args;
}
eepromSetWriteMode();
// write input line instead of static string
for (char* p = writeStr; *p != '\0'; p++) {
eepromWriteByte(addr, *p);
//_delay_ms(100);
addr++;
}
// TODO necessary?
_delay_ms(100);
uartPutString("TESTWRITE success\r\n");
}
else {
// unknown command: return error message
uartPutString("ERROR invalid command\r\n");
}
}
// Runs main loop to parse commands
void protocolMainLoop() {
while(1) {
// Parse next command
parseNextCommand();
}
}

16
firmware_src/protocol.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef PROTOCOL_H_
#define PROTOCOL_H_
#include "config.h"
#include "protocol.h"
#include "uart.h"
#include "eeprom.h"
// Reads, parses and executes next command
void parseNextCommand();
// Runs main loop to parse commands
void protocolMainLoop();
#endif /* PROTOCOL_H_ */

94
firmware_src/uart.c Normal file
View File

@ -0,0 +1,94 @@
#include "config.h"
#include "uart.h"
#include <avr/io.h>
#include <util/setbaud.h>
// Initialize UART
void uartInit() {
// Set Baud register
UBRRH = UBRRH_VALUE;
UBRRL = UBRRL_VALUE;
// Reset status register
UCSRA = 0x00;
#if USE_2X
// U2X mode necessary
UCSRA |= (1 << U2X);
#else
// U2X mode not necessary
UCSRA &= ~(1 << U2X);
#endif
// Enable transmitter and receiver
UCSRB |= (1 << TXEN) | (1 << RXEN);
// Set frame format (8 bit)
UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0);
}
// Transmit a single character
void uartPutChar(unsigned char data) {
// Block until controller is ready to send
while (!(UCSRA & (1 << UDRE))) {
}
// Write character to UART data register
UDR = data;
}
// Transmit a string
void uartPutString(char* data) {
// Write characters until \0 is reached
while (*data) {
uartPutChar(*data++);
}
}
// Receive a single character (blocking)
unsigned char uartGetChar() {
// Block until a character has been received
while (!(UCSRA & (1 << RXC))) {
}
// Get character and return
return UDR;
}
// Receive a string until \n (blocking)
uint8_t uartGetLine(char* buffer, uint8_t maxLength) {
uint8_t readChars = 0;
unsigned char nextChar;
// Read a maximum of maxLength-1 characters (-1 because we need one char for '\0')
while (readChars < maxLength - 1) {
// Get next character
nextChar = uartGetChar();
// Skip trailing \n and \r
if (nextChar == '\n' || nextChar == '\r') {
if (readChars == 0) {
// Skip trailing \n and \r
continue;
}
else {
// End line (do not append the \r or \n to the buffer)
break;
}
}
// Write character to buffer
*buffer++ = nextChar;
// Increment counter
readChars++;
}
// Write a terminating '\0' byte
*buffer++ = '\0';
// Return number of read bytes (excluding the \0)
return readChars;
}

22
firmware_src/uart.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef UART_H_
#define UART_H_
#include "config.h"
#include <avr/io.h>
// Initialize UART
void uartInit();
// Transmit a single character
void uartPutChar(unsigned char data);
// Transmit a string
void uartPutString(char* data);
// Read a single character (blocking)
unsigned char uartGetChar();
// Read a string until \n (blocking)
uint8_t uartGetLine(char* buffer, uint8_t maxLength);
#endif /* UART_H_ */

5
kicad/README Normal file
View File

@ -0,0 +1,5 @@
Note: The Kicad files seem to be broken. :(
The actual hardware is built on a perfboard right now and slightly different to the Kicad scheme (?).
TODO: Fix Kicad files to actually produce a PCB sometime. :3

274
kicad/eepprog-cache.lib Normal file
View File

@ -0,0 +1,274 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#
# 28C256
#
DEF 28C256 U 0 40 Y Y 1 F N
F0 "U" 200 1000 50 H V C CNN
F1 "28C256" 300 -1000 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
X GND 14 0 -1000 50 U 50 50 0 0 W N
X VCC 28 0 1000 50 D 50 50 0 0 W N
S -400 950 400 -950 0 1 0 N
X A14 1 -700 -500 300 R 50 50 1 1 I
X A12 2 -700 -300 300 R 50 50 1 1 I
X A7 3 -700 200 300 R 50 50 1 1 I
X A6 4 -700 300 300 R 50 50 1 1 I
X A5 5 -700 400 300 R 50 50 1 1 I
X A4 6 -700 500 300 R 50 50 1 1 I
X A3 7 -700 600 300 R 50 50 1 1 I
X A2 8 -700 700 300 R 50 50 1 1 I
X A1 9 -700 800 300 R 50 50 1 1 I
X A0 10 -700 900 300 R 50 50 1 1 I
X CS 20 -700 -900 300 R 50 50 1 1 I L
X D0 11 700 900 300 L 50 50 1 1 T
X A10 21 -700 -100 300 R 50 50 1 1 I
X D1 12 700 800 300 L 50 50 1 1 T
X OE 22 -700 -800 300 R 50 50 1 1 I L
X D2 13 700 700 300 L 50 50 1 1 T
X A11 23 -700 -200 300 R 50 50 1 1 I
X A9 24 -700 0 300 R 50 50 1 1 I
X D3 15 700 600 300 L 50 50 1 1 T
X A8 25 -700 100 300 R 50 50 1 1 I
X D4 16 700 500 300 L 50 50 1 1 T
X A13 26 -700 -400 300 R 50 50 1 1 I
X D5 17 700 400 300 L 50 50 1 1 T
X WE 27 -700 -700 300 R 50 50 1 1 I L
X D6 18 700 300 300 L 50 50 1 1 T
X D7 19 700 200 300 L 50 50 1 1 T
ENDDRAW
ENDDEF
#
# ATMEGA16-16PU
#
DEF ATMEGA16-16PU U 0 40 Y Y 1 F N
F0 "U" -850 1880 50 H V L BNN
F1 "ATMEGA16-16PU" 450 -1950 50 H V L BNN
F2 "DIL40" 0 0 50 H I C CIN
F3 "" 0 0 50 H I C CNN
$FPLIST
40DIP-ELL600
40dip600
$ENDFPLIST
DRAW
S -850 1850 850 -1850 0 1 10 f
X (T0/XCK)PB0 1 1000 800 150 L 40 40 1 1 B
X (T1)PB1 2 1000 700 150 L 40 40 1 1 B
X (AIN0/INT2)PB2 3 1000 600 150 L 40 40 1 1 B
X (AIN1/OC0)PB3 4 1000 500 150 L 40 40 1 1 B
X (~SS~)PB4 5 1000 400 150 L 40 40 1 1 B
X (MOSI)PB5 6 1000 300 150 L 40 40 1 1 B
X (MISO)PB6 7 1000 200 150 L 40 40 1 1 B
X (SCK)PB7 8 1000 100 150 L 40 40 1 1 B
X ~RESET 9 -1000 1700 150 R 40 40 1 1 I
X VCC 10 -150 2000 150 D 40 40 1 1 W
X (ICP)PD6 20 1000 -1600 150 L 40 40 1 1 B
X AVCC 30 150 2000 150 D 40 40 1 1 W
X (ADC0)PA0 40 1000 1700 150 L 40 40 1 1 B
X GND 11 -50 -2000 150 U 40 40 1 1 W
X (OC2)PD7 21 1000 -1700 150 L 40 40 1 1 B
X AGND 31 50 -2000 150 U 40 40 1 1 W
X XTAL2 12 -1000 1300 150 R 40 40 1 1 B
X (SCL)PC0 22 1000 -100 150 L 40 40 1 1 B
X AREF 32 -1000 500 150 R 40 40 1 1 W
X XTAL1 13 -1000 900 150 R 40 40 1 1 B
X (SDA)PC1 23 1000 -200 150 L 40 40 1 1 B
X (ADC7)PA7 33 1000 1000 150 L 40 40 1 1 B
X (RXD)PD0 14 1000 -1000 150 L 40 40 1 1 B
X (TCK)PC2 24 1000 -300 150 L 40 40 1 1 B
X (ADC6)PA6 34 1000 1100 150 L 40 40 1 1 B
X (TXD)PD1 15 1000 -1100 150 L 40 40 1 1 B
X (TMS)PC3 25 1000 -400 150 L 40 40 1 1 B
X (ADC5)PA5 35 1000 1200 150 L 40 40 1 1 B
X (INT0)PD2 16 1000 -1200 150 L 40 40 1 1 B
X (TDO)PC4 26 1000 -500 150 L 40 40 1 1 B
X (ADC4)PA4 36 1000 1300 150 L 40 40 1 1 B
X (INT1)PD3 17 1000 -1300 150 L 40 40 1 1 B
X (TDI)PC5 27 1000 -600 150 L 40 40 1 1 B
X (ADC3)PA3 37 1000 1400 150 L 40 40 1 1 B
X (OC1B)PD4 18 1000 -1400 150 L 40 40 1 1 B
X (TOSC1)PC6 28 1000 -700 150 L 40 40 1 1 B
X (ADC2)PA2 38 1000 1500 150 L 40 40 1 1 B
X (OC1A)PD5 19 1000 -1500 150 L 40 40 1 1 B
X (TOSC2)PC7 29 1000 -800 150 L 40 40 1 1 B
X (ADC1)PA1 39 1000 1600 150 L 40 40 1 1 B
ENDDRAW
ENDDEF
#
# C
#
DEF C C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "C" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
C_*
$ENDFPLIST
DRAW
P 2 0 1 20 -80 -30 80 -30 N
P 2 0 1 20 -80 30 80 30 N
X ~ 1 0 150 110 D 50 50 1 1 P
X ~ 2 0 -150 110 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Conn_01x04
#
DEF Conn_01x04 J 0 40 Y N 1 F N
F0 "J" 0 200 50 H V C CNN
F1 "Conn_01x04" 0 -300 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_??x*mm*
Connector*:*1x??x*mm*
Pin?Header?Straight?1X*
Pin?Header?Angled?1X*
Socket?Strip?Straight?1X*
Socket?Strip?Angled?1X*
$ENDFPLIST
DRAW
S -50 -195 0 -205 1 1 6 N
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 150 50 -250 1 1 10 f
X Pin_1 1 -200 100 150 R 50 50 1 1 P
X Pin_2 2 -200 0 150 R 50 50 1 1 P
X Pin_3 3 -200 -100 150 R 50 50 1 1 P
X Pin_4 4 -200 -200 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Conn_02x03_Odd_Even
#
DEF Conn_02x03_Odd_Even J 0 40 Y N 1 F N
F0 "J" 50 200 50 H V C CNN
F1 "Conn_02x03_Odd_Even" 50 -200 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*2x??x*mm*
Connector*:*2x???Pitch*
Pin_Header_Straight_2X*
Pin_Header_Angled_2X*
Socket_Strip_Straight_2X*
Socket_Strip_Angled_2X*
$ENDFPLIST
DRAW
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 150 150 -150 1 1 10 f
S 150 -95 100 -105 1 1 6 N
S 150 5 100 -5 1 1 6 N
S 150 105 100 95 1 1 6 N
X Pin_1 1 -200 100 150 R 50 50 1 1 P
X Pin_2 2 300 100 150 L 50 50 1 1 P
X Pin_3 3 -200 0 150 R 50 50 1 1 P
X Pin_4 4 300 0 150 L 50 50 1 1 P
X Pin_5 5 -200 -100 150 R 50 50 1 1 P
X Pin_6 6 300 -100 150 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Crystal
#
DEF Crystal Y 0 40 N N 1 F N
F0 "Y" 0 150 50 H V C CNN
F1 "Crystal" 0 -150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Crystal*
$ENDFPLIST
DRAW
S -45 100 45 -100 0 1 12 N
P 2 0 1 0 -100 0 -75 0 N
P 2 0 1 20 -75 -50 -75 50 N
P 2 0 1 20 75 -50 75 50 N
P 2 0 1 0 100 0 75 0 N
X 1 1 -150 0 50 R 50 50 1 1 P
X 2 2 150 0 50 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# GND
#
DEF GND #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -250 50 H I C CNN
F1 "GND" 0 -150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
X GND 1 0 0 0 D 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# PWR_FLAG
#
DEF PWR_FLAG #FLG 0 0 N N 1 F P
F0 "#FLG" 0 75 50 H I C CNN
F1 "PWR_FLAG" 0 150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
X pwr 1 0 0 0 U 50 50 0 0 w
P 6 0 1 0 0 0 0 50 -40 75 0 100 40 75 0 50 N
ENDDRAW
ENDDEF
#
# R
#
DEF R R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "R" 0 0 50 V V C CNN
F2 "" -70 0 50 V I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
R_*
R_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# SW_Push
#
DEF SW_Push SW 0 40 N N 1 F N
F0 "SW" 50 100 50 H V L CNN
F1 "SW_Push" 0 -60 50 H V C CNN
F2 "" 0 200 50 H I C CNN
F3 "" 0 200 50 H I C CNN
DRAW
C -80 0 20 0 1 0 N
C 80 0 20 0 1 0 N
P 2 0 1 0 0 50 0 120 N
P 2 0 1 0 100 50 -100 50 N
X 1 1 -200 0 100 R 50 50 0 1 P
X 2 2 200 0 100 L 50 50 0 1 P
ENDDRAW
ENDDEF
#
# VCC
#
DEF VCC #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "VCC" 0 150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
C 0 75 25 0 1 0 N
P 2 0 1 0 0 0 0 50 N
X VCC 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
#End Library

1064
kicad/eepprog.kicad_pcb Normal file

File diff suppressed because it is too large Load Diff

388
kicad/eepprog.net Normal file
View File

@ -0,0 +1,388 @@
(export (version D)
(design
(source /home/lexi/Projects/Z80_Computer/avr/eeprom_programmer/kicad_atm16/eepprog.sch)
(date "2018-02-03T00:47:37 CET")
(tool "Eeschema 4.0.7")
(sheet (number 1) (name /) (tstamps /)
(title_block
(title)
(company)
(rev)
(date)
(source eepprog.sch)
(comment (number 1) (value ""))
(comment (number 2) (value ""))
(comment (number 3) (value ""))
(comment (number 4) (value "")))))
(components
(comp (ref U1)
(value ATMEGA16-16PU)
(footprint Housings_DIP:DIP-40_W15.24mm_Socket)
(libsource (lib atmel) (part ATMEGA16-16PU))
(sheetpath (names /) (tstamps /))
(tstamp 5A74CEE7))
(comp (ref U2)
(value 28C256)
(footprint Housings_DIP:DIP-28_W15.24mm_Socket)
(libsource (lib memory) (part 28C256))
(sheetpath (names /) (tstamps /))
(tstamp 5A74D0F8))
(comp (ref UART1)
(value Conn_01x04)
(footprint Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm)
(libsource (lib conn) (part Conn_01x04))
(sheetpath (names /) (tstamps /))
(tstamp 5A74DDB8))
(comp (ref R1)
(value 10k)
(footprint Resistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal)
(libsource (lib device) (part R))
(sheetpath (names /) (tstamps /))
(tstamp 5A74E368))
(comp (ref Q1)
(value 16MHz)
(footprint Crystals:Crystal_HC49-U_Vertical)
(libsource (lib device) (part Crystal))
(sheetpath (names /) (tstamps /))
(tstamp 5A74E8D7))
(comp (ref C2)
(value 22pF)
(footprint Capacitors_THT:C_Disc_D3.0mm_W2.0mm_P2.50mm)
(libsource (lib device) (part C))
(sheetpath (names /) (tstamps /))
(tstamp 5A74E91C))
(comp (ref C1)
(value 22pF)
(footprint Capacitors_THT:C_Disc_D3.0mm_W2.0mm_P2.50mm)
(libsource (lib device) (part C))
(sheetpath (names /) (tstamps /))
(tstamp 5A74E959))
(comp (ref SW_RESET1)
(value SW_Push)
(footprint Buttons_Switches_THT:SW_PUSH_6mm_h4.3mm)
(libsource (lib switches) (part SW_Push))
(sheetpath (names /) (tstamps /))
(tstamp 5A74EDF7))
(comp (ref ICSP1)
(value Conn_02x03_Odd_Even)
(footprint Pin_Headers:Pin_Header_Straight_2x03_Pitch2.54mm)
(libsource (lib conn) (part Conn_02x03_Odd_Even))
(sheetpath (names /) (tstamps /))
(tstamp 5A75183A))
(comp (ref C4)
(value 100nF)
(footprint Capacitors_THT:C_Disc_D3.0mm_W2.0mm_P2.50mm)
(libsource (lib device) (part C))
(sheetpath (names /) (tstamps /))
(tstamp 5A756F33))
(comp (ref C3)
(value 47nF)
(footprint Capacitors_THT:C_Disc_D3.0mm_W2.0mm_P2.50mm)
(libsource (lib device) (part C))
(sheetpath (names /) (tstamps /))
(tstamp 5A75701A)))
(libparts
(libpart (lib memory) (part 28C256)
(description "EEROM 32Kx8bits")
(docs memory/28c256.pdf)
(fields
(field (name Reference) U)
(field (name Value) 28C256))
(pins
(pin (num 1) (name A14) (type input))
(pin (num 2) (name A12) (type input))
(pin (num 3) (name A7) (type input))
(pin (num 4) (name A6) (type input))
(pin (num 5) (name A5) (type input))
(pin (num 6) (name A4) (type input))
(pin (num 7) (name A3) (type input))
(pin (num 8) (name A2) (type input))
(pin (num 9) (name A1) (type input))
(pin (num 10) (name A0) (type input))
(pin (num 11) (name D0) (type 3state))
(pin (num 12) (name D1) (type 3state))
(pin (num 13) (name D2) (type 3state))
(pin (num 14) (name GND) (type power_in))
(pin (num 15) (name D3) (type 3state))
(pin (num 16) (name D4) (type 3state))
(pin (num 17) (name D5) (type 3state))
(pin (num 18) (name D6) (type 3state))
(pin (num 19) (name D7) (type 3state))
(pin (num 20) (name CS) (type input))
(pin (num 21) (name A10) (type input))
(pin (num 22) (name OE) (type input))
(pin (num 23) (name A11) (type input))
(pin (num 24) (name A9) (type input))
(pin (num 25) (name A8) (type input))
(pin (num 26) (name A13) (type input))
(pin (num 27) (name WE) (type input))
(pin (num 28) (name VCC) (type power_in))))
(libpart (lib atmel) (part ATMEGA16-16PU)
(description "PDIP40, 16k Flash, 1k SRAM, 512B EEPROM, JTAG")
(docs http://www.atmel.com/Images/doc2466.pdf)
(footprints
(fp 40DIP-ELL600)
(fp 40dip600))
(fields
(field (name Reference) U)
(field (name Value) ATMEGA16-16PU)
(field (name Footprint) DIL40))
(pins
(pin (num 1) (name "(T0/XCK)PB0") (type BiDi))
(pin (num 2) (name "(T1)PB1") (type BiDi))
(pin (num 3) (name "(AIN0/INT2)PB2") (type BiDi))
(pin (num 4) (name "(AIN1/OC0)PB3") (type BiDi))
(pin (num 5) (name "(~SS~)PB4") (type BiDi))
(pin (num 6) (name "(MOSI)PB5") (type BiDi))
(pin (num 7) (name "(MISO)PB6") (type BiDi))
(pin (num 8) (name "(SCK)PB7") (type BiDi))
(pin (num 9) (name ~RESET) (type input))
(pin (num 10) (name VCC) (type power_in))
(pin (num 11) (name GND) (type power_in))
(pin (num 12) (name XTAL2) (type BiDi))
(pin (num 13) (name XTAL1) (type BiDi))
(pin (num 14) (name "(RXD)PD0") (type BiDi))
(pin (num 15) (name "(TXD)PD1") (type BiDi))
(pin (num 16) (name "(INT0)PD2") (type BiDi))
(pin (num 17) (name "(INT1)PD3") (type BiDi))
(pin (num 18) (name "(OC1B)PD4") (type BiDi))
(pin (num 19) (name "(OC1A)PD5") (type BiDi))
(pin (num 20) (name "(ICP)PD6") (type BiDi))
(pin (num 21) (name "(OC2)PD7") (type BiDi))
(pin (num 22) (name "(SCL)PC0") (type BiDi))
(pin (num 23) (name "(SDA)PC1") (type BiDi))
(pin (num 24) (name "(TCK)PC2") (type BiDi))
(pin (num 25) (name "(TMS)PC3") (type BiDi))
(pin (num 26) (name "(TDO)PC4") (type BiDi))
(pin (num 27) (name "(TDI)PC5") (type BiDi))
(pin (num 28) (name "(TOSC1)PC6") (type BiDi))
(pin (num 29) (name "(TOSC2)PC7") (type BiDi))
(pin (num 30) (name AVCC) (type power_in))
(pin (num 31) (name AGND) (type power_in))
(pin (num 32) (name AREF) (type power_in))
(pin (num 33) (name "(ADC7)PA7") (type BiDi))
(pin (num 34) (name "(ADC6)PA6") (type BiDi))
(pin (num 35) (name "(ADC5)PA5") (type BiDi))
(pin (num 36) (name "(ADC4)PA4") (type BiDi))
(pin (num 37) (name "(ADC3)PA3") (type BiDi))
(pin (num 38) (name "(ADC2)PA2") (type BiDi))
(pin (num 39) (name "(ADC1)PA1") (type BiDi))
(pin (num 40) (name "(ADC0)PA0") (type BiDi))))
(libpart (lib device) (part C)
(description "Unpolarized capacitor")
(footprints
(fp C_*))
(fields
(field (name Reference) C)
(field (name Value) C))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib conn) (part Conn_01x04)
(description "Generic connector, single row, 01x04")
(docs ~)
(footprints
(fp Connector*:*_??x*mm*)
(fp Connector*:*1x??x*mm*)
(fp Pin?Header?Straight?1X*)
(fp Pin?Header?Angled?1X*)
(fp Socket?Strip?Straight?1X*)
(fp Socket?Strip?Angled?1X*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x04))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))
(pin (num 4) (name Pin_4) (type passive))))
(libpart (lib conn) (part Conn_02x03_Odd_Even)
(description "Generic connector, double row, 02x03, odd/even pin numbering scheme (row 1 odd numbers, row 2 even numbers)")
(docs ~)
(footprints
(fp Connector*:*2x??x*mm*)
(fp Connector*:*2x???Pitch*)
(fp Pin_Header_Straight_2X*)
(fp Pin_Header_Angled_2X*)
(fp Socket_Strip_Straight_2X*)
(fp Socket_Strip_Angled_2X*))
(fields
(field (name Reference) J)
(field (name Value) Conn_02x03_Odd_Even))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))
(pin (num 4) (name Pin_4) (type passive))
(pin (num 5) (name Pin_5) (type passive))
(pin (num 6) (name Pin_6) (type passive))))
(libpart (lib device) (part Crystal)
(description "Two pin crystal")
(footprints
(fp Crystal*))
(fields
(field (name Reference) Y)
(field (name Value) Crystal))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib device) (part R)
(description Resistor)
(footprints
(fp R_*)
(fp R_*))
(fields
(field (name Reference) R)
(field (name Value) R))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib switches) (part SW_Push)
(description "Push button switch, generic, two pins")
(fields
(field (name Reference) SW)
(field (name Value) SW_Push))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive)))))
(libraries
(library (logical device)
(uri /usr/share/kicad/library/device.lib))
(library (logical switches)
(uri /usr/share/kicad/library/switches.lib))
(library (logical conn)
(uri /usr/share/kicad/library/conn.lib))
(library (logical memory)
(uri /usr/share/kicad/library/memory.lib))
(library (logical atmel)
(uri /usr/share/kicad/library/atmel.lib)))
(nets
(net (code 1) (name "Net-(C2-Pad1)")
(node (ref C2) (pin 1))
(node (ref U1) (pin 12))
(node (ref Q1) (pin 1)))
(net (code 2) (name "Net-(C1-Pad1)")
(node (ref C1) (pin 1))
(node (ref Q1) (pin 2))
(node (ref U1) (pin 13)))
(net (code 3) (name "Net-(U1-Pad14)")
(node (ref UART1) (pin 4))
(node (ref U1) (pin 14)))
(net (code 4) (name "Net-(U1-Pad15)")
(node (ref UART1) (pin 3))
(node (ref U1) (pin 15)))
(net (code 5) (name "Net-(U1-Pad35)")
(node (ref U2) (pin 17))
(node (ref U1) (pin 35)))
(net (code 6) (name "Net-(U1-Pad36)")
(node (ref U2) (pin 16))
(node (ref U1) (pin 36)))
(net (code 7) (name "Net-(U1-Pad37)")
(node (ref U1) (pin 37))
(node (ref U2) (pin 15)))
(net (code 8) (name "Net-(U1-Pad38)")
(node (ref U2) (pin 13))
(node (ref U1) (pin 38)))
(net (code 9) (name "Net-(U1-Pad39)")
(node (ref U1) (pin 39))
(node (ref U2) (pin 12)))
(net (code 10) (name "Net-(U1-Pad40)")
(node (ref U2) (pin 11))
(node (ref U1) (pin 40)))
(net (code 11) (name "Net-(U1-Pad16)")
(node (ref U2) (pin 20))
(node (ref U1) (pin 16)))
(net (code 12) (name "Net-(U1-Pad17)")
(node (ref U2) (pin 22))
(node (ref U1) (pin 17)))
(net (code 13) (name "Net-(U1-Pad18)")
(node (ref U1) (pin 18))
(node (ref U2) (pin 27)))
(net (code 14) (name GND)
(node (ref ICSP1) (pin 6))
(node (ref SW_RESET1) (pin 1))
(node (ref C1) (pin 2))
(node (ref C2) (pin 2))
(node (ref U2) (pin 14))
(node (ref UART1) (pin 1))
(node (ref U1) (pin 31))
(node (ref U1) (pin 32))
(node (ref U1) (pin 11))
(node (ref C3) (pin 2))
(node (ref C4) (pin 2)))
(net (code 15) (name "Net-(C3-Pad1)")
(node (ref ICSP1) (pin 5))
(node (ref C3) (pin 1))
(node (ref SW_RESET1) (pin 2))
(node (ref R1) (pin 2))
(node (ref U1) (pin 9)))
(net (code 16) (name "Net-(U1-Pad19)")
(node (ref U1) (pin 19)))
(net (code 17) (name "Net-(U1-Pad20)")
(node (ref U1) (pin 20)))
(net (code 18) (name "Net-(U1-Pad21)")
(node (ref U1) (pin 21)))
(net (code 19) (name VCC)
(node (ref UART1) (pin 2))
(node (ref U1) (pin 30))
(node (ref R1) (pin 1))
(node (ref U1) (pin 10))
(node (ref C4) (pin 1))
(node (ref ICSP1) (pin 2))
(node (ref U2) (pin 28)))
(net (code 20) (name "Net-(ICSP1-Pad3)")
(node (ref ICSP1) (pin 3))
(node (ref U1) (pin 8)))
(net (code 21) (name "Net-(U1-Pad29)")
(node (ref U2) (pin 3))
(node (ref U1) (pin 29)))
(net (code 22) (name "Net-(ICSP1-Pad1)")
(node (ref U2) (pin 1))
(node (ref U1) (pin 7))
(node (ref ICSP1) (pin 1)))
(net (code 23) (name "Net-(U1-Pad5)")
(node (ref U1) (pin 5))
(node (ref U2) (pin 2)))
(net (code 24) (name "Net-(U1-Pad28)")
(node (ref U1) (pin 28))
(node (ref U2) (pin 4)))
(net (code 25) (name "Net-(U1-Pad27)")
(node (ref U2) (pin 5))
(node (ref U1) (pin 27)))
(net (code 26) (name "Net-(U1-Pad3)")
(node (ref U2) (pin 21))
(node (ref U1) (pin 3)))
(net (code 27) (name "Net-(U1-Pad2)")
(node (ref U2) (pin 24))
(node (ref U1) (pin 2)))
(net (code 28) (name "Net-(U1-Pad4)")
(node (ref U1) (pin 4))
(node (ref U2) (pin 23)))
(net (code 29) (name "Net-(ICSP1-Pad4)")
(node (ref U2) (pin 26))
(node (ref ICSP1) (pin 4))
(node (ref U1) (pin 6)))
(net (code 30) (name "Net-(U1-Pad22)")
(node (ref U2) (pin 10))
(node (ref U1) (pin 22)))
(net (code 31) (name "Net-(U1-Pad23)")
(node (ref U2) (pin 9))
(node (ref U1) (pin 23)))
(net (code 32) (name "Net-(U1-Pad33)")
(node (ref U1) (pin 33))
(node (ref U2) (pin 19)))
(net (code 33) (name "Net-(U1-Pad24)")
(node (ref U1) (pin 24))
(node (ref U2) (pin 8)))
(net (code 34) (name "Net-(U1-Pad25)")
(node (ref U2) (pin 7))
(node (ref U1) (pin 25)))
(net (code 35) (name "Net-(U1-Pad26)")
(node (ref U2) (pin 6))
(node (ref U1) (pin 26)))
(net (code 36) (name "Net-(U1-Pad1)")
(node (ref U1) (pin 1))
(node (ref U2) (pin 25)))
(net (code 37) (name "Net-(U1-Pad34)")
(node (ref U1) (pin 34))
(node (ref U2) (pin 18)))))

30
kicad/eepprog.pro Normal file
View File

@ -0,0 +1,30 @@
update=2018-08-08T20:51:05 CEST
version=1
last_client=kicad
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.000000000000
SolderMaskMinWidth=0.000000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
[general]
version=1
[cvpcb]
version=1
NetIExt=net
[eeschema]
version=1
LibDir=

489
kicad/eepprog.sch Normal file
View File

@ -0,0 +1,489 @@
EESchema Schematic File Version 2
LIBS:power
LIBS:device
LIBS:switches
LIBS:relays
LIBS:motors
LIBS:transistors
LIBS:conn
LIBS:linear
LIBS:regul
LIBS:74xx
LIBS:cmos4000
LIBS:adc-dac
LIBS:memory
LIBS:xilinx
LIBS:microcontrollers
LIBS:dsp
LIBS:microchip
LIBS:analog_switches
LIBS:motorola
LIBS:texas
LIBS:intel
LIBS:audio
LIBS:interface
LIBS:digital-audio
LIBS:philips
LIBS:display
LIBS:cypress
LIBS:siliconi
LIBS:opto
LIBS:atmel
LIBS:contrib
LIBS:valves
EELAYER 25 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L ATMEGA16-16PU U1
U 1 1 5A74CEE7
P 3350 3850
F 0 "U1" H 2500 5730 50 0000 L BNN
F 1 "ATMEGA16-16PU" H 3800 1900 50 0000 L BNN
F 2 "DIL40" H 3350 3850 50 0001 C CIN
F 3 "" H 3350 3850 50 0001 C CNN
1 3350 3850
1 0 0 -1
$EndComp
$Comp
L 28C256 U2
U 1 1 5A74D0F8
P 6000 4850
F 0 "U2" H 6200 5850 50 0000 C CNN
F 1 "28C256" H 6300 3850 50 0000 C CNN
F 2 "" H 6000 4850 50 0001 C CNN
F 3 "" H 6000 4850 50 0001 C CNN
1 6000 4850
1 0 0 -1
$EndComp
$Comp
L Conn_01x04 UART1
U 1 1 5A74DDB8
P 1950 6250
F 0 "UART1" H 1950 6450 50 0000 C CNN
F 1 "Conn_01x04" H 1900 5950 50 0001 C CNN
F 2 "" H 1950 6250 50 0001 C CNN
F 3 "" H 1950 6250 50 0001 C CNN
1 1950 6250
-1 0 0 1
$EndComp
$Comp
L VCC #PWR01
U 1 1 5A74E1AA
P 3200 1600
F 0 "#PWR01" H 3200 1450 50 0001 C CNN
F 1 "VCC" H 3200 1750 50 0000 C CNN
F 2 "" H 3200 1600 50 0001 C CNN
F 3 "" H 3200 1600 50 0001 C CNN
1 3200 1600
1 0 0 -1
$EndComp
$Comp
L R R1
U 1 1 5A74E368
P 2750 1750
F 0 "R1" V 2830 1750 50 0000 C CNN
F 1 "10k" V 2750 1750 50 0000 C CNN
F 2 "" V 2680 1750 50 0001 C CNN
F 3 "" H 2750 1750 50 0001 C CNN
1 2750 1750
0 1 1 0
$EndComp
$Comp
L Crystal Q1
U 1 1 5A74E8D7
P 2150 2750
F 0 "Q1" H 2150 2900 50 0000 C CNN
F 1 "16MHz" H 2150 2600 50 0000 C CNN
F 2 "" H 2150 2750 50 0001 C CNN
F 3 "" H 2150 2750 50 0001 C CNN
1 2150 2750
0 1 1 0
$EndComp
$Comp
L C C2
U 1 1 5A74E91C
P 1800 2550
F 0 "C2" H 1825 2650 50 0000 L CNN
F 1 "22pF" H 1825 2450 50 0000 L CNN
F 2 "" H 1838 2400 50 0001 C CNN
F 3 "" H 1800 2550 50 0001 C CNN
1 1800 2550
0 1 1 0
$EndComp
$Comp
L C C1
U 1 1 5A74E959
P 1800 2950
F 0 "C1" H 1825 3050 50 0000 L CNN
F 1 "22pF" H 1825 2850 50 0000 L CNN
F 2 "" H 1838 2800 50 0001 C CNN
F 3 "" H 1800 2950 50 0001 C CNN
1 1800 2950
0 1 1 0
$EndComp
$Comp
L GND #PWR02
U 1 1 5A74ED50
P 1400 3600
F 0 "#PWR02" H 1400 3350 50 0001 C CNN
F 1 "GND" H 1400 3450 50 0000 C CNN
F 2 "" H 1400 3600 50 0001 C CNN
F 3 "" H 1400 3600 50 0001 C CNN
1 1400 3600
1 0 0 -1
$EndComp
$Comp
L SW_Push SW_RESET1
U 1 1 5A74EDF7
P 1900 2150
F 0 "SW_RESET1" H 1700 2050 50 0000 L CNN
F 1 "SW_Push" H 1900 2090 50 0001 C CNN
F 2 "" H 1900 2350 50 0001 C CNN
F 3 "" H 1900 2350 50 0001 C CNN
1 1900 2150
1 0 0 -1
$EndComp
Wire Wire Line
4350 3950 5300 3950
Wire Wire Line
4350 4050 5300 4050
Wire Wire Line
4350 4150 5300 4150
Wire Wire Line
4350 4250 5300 4250
Wire Wire Line
4350 4350 5300 4350
Wire Wire Line
4350 4450 5300 4450
Wire Wire Line
4350 4550 5300 4550
Wire Wire Line
4350 4650 5300 4650
Wire Wire Line
4350 3050 5150 3050
Wire Wire Line
5150 3050 5150 4750
Wire Wire Line
5150 4750 5300 4750
Wire Wire Line
4350 3150 5100 3150
Wire Wire Line
5100 3150 5100 4850
Wire Wire Line
5100 4850 5300 4850
Wire Wire Line
5300 4950 5050 4950
Wire Wire Line
5050 4950 5050 3250
Wire Wire Line
5050 3250 4350 3250
Wire Wire Line
4350 3350 5000 3350
Wire Wire Line
5000 3350 5000 5050
Wire Wire Line
5000 5050 5300 5050
Wire Wire Line
5300 5150 4950 5150
Wire Wire Line
4950 5150 4950 3450
Wire Wire Line
4950 3450 4350 3450
Wire Wire Line
4350 3550 4900 3550
Wire Wire Line
4900 3550 4900 5250
Wire Wire Line
4900 5250 5300 5250
Wire Wire Line
5300 5350 4850 5350
Wire Wire Line
4850 5350 4850 3650
Wire Wire Line
4850 3650 4350 3650
Wire Wire Line
4350 2850 6800 2850
Wire Wire Line
6800 2850 6800 4650
Wire Wire Line
6800 4650 6700 4650
Wire Wire Line
6700 4550 6850 4550
Wire Wire Line
6850 4550 6850 2750
Wire Wire Line
6850 2750 4350 2750
Wire Wire Line
4350 2650 6900 2650
Wire Wire Line
6900 2650 6900 4450
Wire Wire Line
6900 4450 6700 4450
Wire Wire Line
6700 4350 6950 4350
Wire Wire Line
6950 4350 6950 2550
Wire Wire Line
6950 2550 4350 2550
Wire Wire Line
4350 2450 7000 2450
Wire Wire Line
7000 2450 7000 4250
Wire Wire Line
7000 4250 6700 4250
Wire Wire Line
6700 4150 7050 4150
Wire Wire Line
7050 4150 7050 2350
Wire Wire Line
7050 2350 4350 2350
Wire Wire Line
4350 2250 7100 2250
Wire Wire Line
7100 2250 7100 4050
Wire Wire Line
7100 4050 6700 4050
Wire Wire Line
6700 3950 7150 3950
Wire Wire Line
7150 3950 7150 2150
Wire Wire Line
7150 2150 4350 2150
Wire Wire Line
4350 5050 4750 5050
Wire Wire Line
4750 5050 4750 5750
Wire Wire Line
4750 5750 5300 5750
Wire Wire Line
4350 5150 4700 5150
Wire Wire Line
4700 5150 4700 5650
Wire Wire Line
4700 5650 5300 5650
Wire Wire Line
5300 5550 4650 5550
Wire Wire Line
4650 5550 4650 5250
Wire Wire Line
4650 5250 4350 5250
Wire Wire Line
3200 1600 3200 1850
Wire Wire Line
2900 1750 3500 1750
Wire Wire Line
3500 1750 3500 1850
Connection ~ 3200 1750
Wire Wire Line
2600 1750 2250 1750
Wire Wire Line
2250 1300 2250 2150
Wire Wire Line
2100 2150 2350 2150
Wire Wire Line
1950 2550 2350 2550
Wire Wire Line
2150 2550 2150 2600
Connection ~ 2150 2550
Wire Wire Line
1950 2950 2350 2950
Wire Wire Line
2150 2900 2150 2950
Connection ~ 2150 2950
Wire Wire Line
1350 3350 2350 3350
Connection ~ 1400 3350
Connection ~ 2250 2150
Wire Wire Line
1650 2550 1600 2550
Wire Wire Line
1600 2550 1600 2950
Wire Wire Line
1600 2950 1650 2950
Wire Wire Line
1600 2750 1400 2750
Wire Wire Line
1400 2150 1400 3600
Connection ~ 1600 2750
Wire Wire Line
1700 2150 1400 2150
Connection ~ 1400 2750
Wire Wire Line
3300 5850 3300 6450
Wire Wire Line
3300 6350 2150 6350
Wire Wire Line
3400 5850 3400 5900
Wire Wire Line
3400 5900 3300 5900
Connection ~ 3300 5900
Wire Wire Line
4350 4850 4550 4850
Wire Wire Line
4550 4850 4550 6050
Wire Wire Line
4550 6050 2150 6050
Wire Wire Line
4350 4950 4500 4950
Wire Wire Line
4500 4950 4500 6150
Wire Wire Line
4500 6150 2150 6150
$Comp
L VCC #PWR03
U 1 1 5A75113A
P 2300 5550
F 0 "#PWR03" H 2300 5400 50 0001 C CNN
F 1 "VCC" H 2300 5700 50 0000 C CNN
F 2 "" H 2300 5550 50 0001 C CNN
F 3 "" H 2300 5550 50 0001 C CNN
1 2300 5550
1 0 0 -1
$EndComp
$Comp
L GND #PWR04
U 1 1 5A751166
P 3300 6450
F 0 "#PWR04" H 3300 6200 50 0001 C CNN
F 1 "GND" H 3300 6300 50 0000 C CNN
F 2 "" H 3300 6450 50 0001 C CNN
F 3 "" H 3300 6450 50 0001 C CNN
1 3300 6450
1 0 0 -1
$EndComp
Connection ~ 3300 6350
Wire Wire Line
2300 5550 2300 6250
Wire Wire Line
2300 6250 2150 6250
$Comp
L Conn_02x03_Odd_Even ICSP1
U 1 1 5A75183A
P 5150 1200
F 0 "ICSP1" H 5200 1400 50 0000 C CNN
F 1 "Conn_02x03_Odd_Even" H 5200 1000 50 0001 C CNN
F 2 "" H 5150 1200 50 0001 C CNN
F 3 "" H 5150 1200 50 0001 C CNN
1 5150 1200
1 0 0 -1
$EndComp
Wire Wire Line
4950 1100 4600 1100
Wire Wire Line
4600 1100 4600 3650
Connection ~ 4600 3650
Wire Wire Line
4950 1200 4650 1200
Wire Wire Line
4650 1200 4650 3750
Wire Wire Line
4650 3750 4350 3750
Wire Wire Line
4700 3550 4700 1400
Wire Wire Line
4700 1400 5500 1400
Wire Wire Line
5500 1400 5500 1200
Wire Wire Line
5500 1200 5450 1200
Connection ~ 4700 3550
$Comp
L GND #PWR05
U 1 1 5A7521B1
P 5650 1500
F 0 "#PWR05" H 5650 1250 50 0001 C CNN
F 1 "GND" H 5650 1350 50 0000 C CNN
F 2 "" H 5650 1500 50 0001 C CNN
F 3 "" H 5650 1500 50 0001 C CNN
1 5650 1500
1 0 0 -1
$EndComp
$Comp
L VCC #PWR06
U 1 1 5A7521E0
P 5650 950
F 0 "#PWR06" H 5650 800 50 0001 C CNN
F 1 "VCC" H 5650 1100 50 0000 C CNN
F 2 "" H 5650 950 50 0001 C CNN
F 3 "" H 5650 950 50 0001 C CNN
1 5650 950
1 0 0 -1
$EndComp
Wire Wire Line
5450 1300 5650 1300
Wire Wire Line
5650 1300 5650 1500
Wire Wire Line
5450 1100 5650 1100
Wire Wire Line
5650 1100 5650 950
Wire Wire Line
4950 1300 2250 1300
Connection ~ 2250 1750
NoConn ~ 4350 5350
NoConn ~ 4350 5450
NoConn ~ 4350 5550
$Comp
L PWR_FLAG #FLG07
U 1 1 5A755DD8
P 2250 5800
F 0 "#FLG07" H 2250 5875 50 0001 C CNN
F 1 "PWR_FLAG" H 2250 5950 50 0000 C CNN
F 2 "" H 2250 5800 50 0001 C CNN
F 3 "" H 2250 5800 50 0001 C CNN
1 2250 5800
0 -1 -1 0
$EndComp
Wire Wire Line
2250 5800 2300 5800
Connection ~ 2300 5800
$Comp
L VCC #PWR08
U 1 1 5A756502
P 6000 3600
F 0 "#PWR08" H 6000 3450 50 0001 C CNN
F 1 "VCC" H 6000 3750 50 0000 C CNN
F 2 "" H 6000 3600 50 0001 C CNN
F 3 "" H 6000 3600 50 0001 C CNN
1 6000 3600
1 0 0 -1
$EndComp
Wire Wire Line
6000 3600 6000 3850
$Comp
L GND #PWR09
U 1 1 5A756709
P 6000 6050
F 0 "#PWR09" H 6000 5800 50 0001 C CNN
F 1 "GND" H 6000 5900 50 0000 C CNN
F 2 "" H 6000 6050 50 0001 C CNN
F 3 "" H 6000 6050 50 0001 C CNN
1 6000 6050
1 0 0 -1
$EndComp
Wire Wire Line
6000 5850 6000 6050
$Comp
L PWR_FLAG #FLG010
U 1 1 5A7568D4
P 1350 3350
F 0 "#FLG010" H 1350 3425 50 0001 C CNN
F 1 "PWR_FLAG" H 1350 3500 50 0000 C CNN
F 2 "" H 1350 3350 50 0001 C CNN
F 3 "" H 1350 3350 50 0001 C CNN
1 1350 3350
0 -1 -1 0
$EndComp
$EndSCHEMATC

85
pin_allocation.txt Normal file
View File

@ -0,0 +1,85 @@
Microcontroller:
- ATmega16 (32 IO-Pins)
- available IO pins:
- PA0-7
- PB0-7 (including PB5-7 for ISP)
- PC0-7
- PD2-7 (PD0 and PD1 are UART pins)
EEPROM:
- Atmel AT28C256
- IO and control pins:
- 8 data lines (I/O) D0-7
- 15 address lines A0-14
- inverted Chip Enable ~CE
- inverted Output Enable ~OE
- inverted Write Enable ~WE
Usage
-----
- 1 microcontroller (µC), 1 EEPROM
- direct parallel data IO
Pin allocation
--------------
- on µC
- PC0-7 --> EEPROM address lines A0-7
- PB0-6 --> EEPROM address lines A8-14
- PA0-7 <-> EEPROM data lines D0-7
- PD0-1 <-> UART TX/RX
- PD2 --> EEPROM ~CE
- PD3 --> EEPROM ~OE
- PD4 --> EEPROM ~WE
- on EEPROM
(see µC)
Reading process
---------------
1. reset EEPROM control bits to [chip disabled, output disabled, write disabled]
PORTD2..4 = 111
2. set data pins as inputs (without pullups - maybe disable pullups at all (PUD in SFIOR))
DDA0..7 = 00000000
PORTA0..7 = 00000000
3. set address
PORTC0..7 = [Address bits 0..7]
PORTB0..6 = [Address bits 0..6]
4. set EEPROM to read mode by enabling chip and output [chip enabled, output enabled, write disabled]
PORTD2..4 = 001
5. wait ~150ns
6. read byte from data pins
DATABYTE0..7 = PINA0..7
7. reset control bits
PORTD2..4 = 111
8. to read next byte, continue at step 3.
Writing process
---------------
1. reset EEPROM control bits (see reading)
PORTD2..4 = 111
2. set data pins as outputs (and reset output pins)
DDA0..7 = 11111111
PORTA0..7 = 00000000
3. set address
PORTC0..7 = [Address bits 0..7]
PORTB0..6 = [Address bits 0..6]
4. set control bits to latch address (falling edge)
PORTD2..4 = 010
5. set data output to the value to be written
PORTA0..7 = WRITEBYTE0..7
6. wait 50ns (data setup time)
7. set control bits to latch data and start write cycle (rising edge)
PORTD2..4 = 111
8. wait 50ns (pulse width)
9. WAIT UNTIL WRITING IS FINISHED
(we can poll D7 to check if write cycle is finished - do we want to do that?)
10. to write next byte, continue at step 3.
Page writing
------------
/* TODO */

137
prog_tool/eepprog.py Executable file
View File

@ -0,0 +1,137 @@
#!/usr/bin/env python3
import sys
import getopt
import serial
# Global variables for program parameters
verbose = False
serial_device = "/dev/ttyUSB0"
serial_baudrate = 9600
command = ""
# Valid commands
valid_commands = ("test")
def usage():
"""Prints help text."""
print(f"""
Usage: {sys.argv[0]} [OPTIONS] COMMAND [ARGS]
Commands:
test first test command...
Options:
-h, --help show this help message and exit
-v, --verbose be verbose
-d DEVICE, --device=DEVICE use DEVICE as serial device
(default: /dev/ttyUSB0)
"""[1:-1])
def parse_args():
"""Parse command line arguments and set global variables."""
# Global variables for program options (yes, yes, I know...)
global verbose, serial_device, serial_baudrate, command
try:
# Try to parse argument strings
optlist, args = getopt.gnu_getopt(
sys.argv[1:],
"hvd:",
["help", "verbose", "device="]
)
except getopt.GetoptError as err:
# Invalid option, print help and exit
print(err, "\n")
usage()
sys.exit(2)
# Parse all the options
for opt, val in optlist:
if opt == "-h" or opt == "--help":
# Print help
usage()
sys.exit()
elif opt == "-v" or opt == "--verbose":
# Verbose
verbose = True
elif opt == "-d" or opt == "--device":
# Set device filename
serial_device = val
else:
assert False, "unhandled option"
# Parse command argument
if len(args) == 0:
print("missing command\n")
usage()
sys.exit(2)
else:
# Get command and remove argument
command = args.pop(0)
# Check if command is valid
if command not in valid_commands:
print("invalid command '" + command + "'\n")
usage()
sys.exit(2)
# Check if command has valid arguments
# TODO
def setup_serial():
"""Setup serial device."""
if verbose:
print(f"setting up serial device '{serial_device}' with baudrate "
f"{serial_baudrate}")
# Setup serial device
ser = serial.Serial(serial_device, serial_baudrate)
return ser
def command_test(ser):
"""Command 'test': Does some testing."""
if verbose:
print("running command 'test' ...")
# Write a test command
# TODO do a HELLO first
ser.write(b"TESTREAD\n")
# Just read some stuff
while True:
print("read: ", ser.readline(80))
def main():
"""Main function. Does the thing."""
# Parse program arguments
parse_args()
# Setup serial device
ser = setup_serial()
# Run command
if command == "test":
command_test(ser)
else:
assert False, "unhandled command"
# Close serial device
ser.close()
# Run program
main()