33
A Design Example A Programmable Calculator

A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Embed Size (px)

DESCRIPTION

Hardware Specifications Keyboard with 64 (8x8) Keys 8 Seven-Segment Display Timer Options: hh – mm – ss 8087 Coprocessor  Maximum Mode DMA 8237 for Fast Data Transfer UART 8250 for RS232 Port RAM ( FFFF) – EPROM (80000-FFFFF) Clock = *16*4= Hz =7.3728MHz

Citation preview

Page 1: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

A Design Example

A Programmable Calculator

Page 2: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Programmable Calculator

• Working in Exact Mode• Receiving Program from RS232 Port• Saving Programs using RS232 Port• Memory Fill/View/Edit/Search• Switch to floating point calculator• Using DMA for Large Data Transfer

Page 3: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Hardware Specifications

• Keyboard with 64 (8x8) Keys• 8 Seven-Segment Display• Timer Options: hh – mm – ss• 8087 Coprocessor Maximum Mode• DMA 8237 for Fast Data Transfer• UART 8250 for RS232 Port• RAM (00000-7FFFF) – EPROM (80000-FFFFF)• Clock = 115200*16*4=7372800 Hz

=7.3728MHz

Page 4: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

CPU Pins in Maximum Mode

GNDAD14AD13AD12AD11AD10AD9AD8AD7AD6AD5AD4AD3AD2AD1AD0NMIINTRCLKGND

VCCAD15A16/S3A17/S4A18/S5A19/S6

RQ/GT0RQ/GT1

QS0

READYRESET

BHE/S7MN/MXRD

LOCKS2S1S0

QS1TEST

1234567891011121314151617181920

3130292827262524232221

4039383736353433328086

Max Mode

GND

Page 5: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

S2 S1 S0 Characteristics

0 0 0 Interrupt acknowledge

0 0 1 Read I/O port0 1 0 Write I/O port0 1 1 Halt1 0 0 Code access1 0 1 Read memory1 1 0 Write memory

1 1 1 Passive State

S0, S1 and S2 Signals

Page 6: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

8086

CP

U

Clockgenerator

Wait-StateGenerator

CLK

READY

RESET

MN/MX

AD0-AD 15A16-A19 BHE

STBOE

8282Latch

A0 - A19

Address Bus

+5V

RESS0S1S2

CLKS0

S1S2

DATA

8286Transceiver

T

OE

ALE

Gnd

DEN

DT/R

MRDC

MWTC

IORC

IOW C

AIOW C

AMWC

INTA

8288

Bus

Con

trolle

r

8086 System Maximum Mode

Page 7: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

8284 Clock Generator for 8086

an 18-pin chip• specially designed to be used with 8088/86 microprocessors,• It provides the clock and synchronization for the microprocessor,• also provides the READY signal for the insertion of wait states into the CPU bus cycle.

Page 8: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

7.3728MHz

22.1184MHz

Page 9: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Bank Write and Bank Read Control Logic

Bank Write Control Logic Bank Read Control Logic

A0 A0

2 EPROMs Each 256KB = 256Kx8 = Eight 27512 or 285122 SRAMs Each 256KB = 256Kx8 = Eight 62512 or 61512Total 1M

Page 10: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOEWE

D0 - D7

D8 - D15A1-A16

A1-A16

Y0Y1Y2Y3Y4Y5Y6Y7

A0A1A2

G1 G2

A17A18A19

A0DEN

Y0Y1Y2Y3Y4Y5Y6Y7

A0A1A2

G1 G2

A17A18A19

BHEDEN

RDL RDL

RDU

RDL

RDU

RDU

RDURDU

WRL

WRU

WRL

WRUWRU

WRLWRL

WRU

SRAMs

Page 11: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15

D0D1D2D3D4D5D6D7

CSOE

D0 - D7

D8 - D15A1-A16

A1-A16

Y0Y1Y2Y3Y4Y5Y6Y7

A0A1A2

G1 G2

A17A18A19

A0DEN

Y0Y1Y2Y3Y4Y5Y6Y7

A0A1A2

G1 G2

A17A18A19

BHEDEN

RDL RDL

RDU

RDL

RDU

RDL

RDURDU

EPROMs

Page 12: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Peripherals

• 8255 (Keyboard)• 8255 (Display)• Timer 8254• 8259 Interrupt Controller• DMA 8237• Coprocessor 8087• UART 8250

Page 13: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Address Decoding for the Peripherals

8086

8255APPI

A0A1

Latch (‘373)

Display

Y0Y1Y2Y3Y4Y5Y6Y7

X0X1X2

A0A1A2A3A4A5A6A7

CS

8259

A0

CS

AD0-AD7

D0-D7Buffer

ALE Keyboard Address: 000XXPP0Timer Address: 010XXPP0Display Address: 011XXPP0UART Address: 101XPPP08259 Address: 110XXXP0DMA Address: 111PPPP0

IR0IR1

DMA

Keyboard

Timer

UART8259

Page 14: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Address Definition

• Keyboard_BASE EQU 0• Display_BASE EQU 60H• Timer_BASE EQU 40H• UART_BASE EQU 0A0H• DMA_BASE EQU 0E0H• 8259_BASE EQU 0C0H

Page 15: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Connecting 8087 to Processor

Page 16: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

8250/16450/16550 UART Connection

A3 A2 A1 (System) A2 A1 A0 (UART)Y5 (Decoder) CS 101XPPP0Line Drivers RS232 io

A0A2A4A6A8AAACADA0A2

Page 17: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Registers

• Transmitter holding register• Receiver buffer register• Interrupt enable register

00001111 A2

Page 18: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Registers

• Interrupt identification register

00000PPP A4

Page 19: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Line Control

00011111 A6 Even Parity, 2 Stop bits, 8 Data bits

Page 20: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Modem Registers

Modem Control Register

Modem Status Register

00000001 A8 DTR Active

status AD

Page 21: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Line Status

Status AA

Page 22: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Divisor Register

Input Clock : 7.3728MHz Required Baud Rate: 9600 bps10000000 A6 DLAB Set0011 0000 A00 A2

Baud Rate Divisor(Decimal) Divisor(hex)

460,800 1 1

115,200 4 4

57,600 8 8

28,800 16 10

38400 12 C

19200 24 18

9600 48 30

Page 23: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Intel Hex Data Format

• : No – Address – Data – Check Sum• :0A 00400 56 78 F6 00 80 80 6C 40 03 02 75

• 56 + 78 + F6 + 80 + 80 + 6C + 40 + 3 + 2 = 375

Page 24: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Commands From RS232

• Upload Data• Download Data• Dump Memory• Fill Memory• Go To Address• Breakpoint• Trace• Register …

Page 25: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Definitions• DISPLAY_SEGMENTS EQU Display_BASE• DISPLAY_GND EQU Display_BASE +2• DISPLAY_CTRL EQU Display_BASE+ 6

• KEYBOARD_ROW EQU Keyboard_BASE• KEYBOARD_COL EQU Keyboard_BASE+2• KEYBOARD_CTRL EQU Keyboard_BASE+6

• TIMER_CH0 EQU Timer_BASE• TIMER_CH1 EQU Timer_BASE+2• TIMER_CH2 EQU Timer_BASE+4• TIMER_CTRL EQU Timer_BASE+6

• IC8259_0 EQU 8259_BASE• IC8259_1 EQU 8259_BASE+2

Page 26: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Main ProgramORG 0FFF0H ;Address FFFF0

• XOR AX,AX ;AX=0• MOV DS,AX ;DS=0• MOV AH,70H ;AX=7000H• MOV SS,AX ;STACK From 7FFFFH• MOV SP,0FFFFH ; SS*10H+SP=7FFFFH• JMP 0F000H:100

Page 27: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

Initialize & Main LOOPORG 100H ;Address F0100

• CLI • CALL INIT_KEYBOARD• CALL INIT_DISPLAY• CALL INIT_TIMER• CALL INIT_8259• CALL INIT_DMA• CALL INIT_RS232• STI

• Main_LOOP:• CALL Keyboard_hit• JZ RS232• CALL GETCH ;Scan Code Available in AL• CALL Process_Key• RS232:• CALL RX_AVAILABLE• JZ Main_LOOP• CALL Process_RX• JMP Main_LOOP

Page 28: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

INIT_KEYBOARD• INIT_KEYBOARD:• MOV AL,00001011B ;Mode0 output for A &• ;Mode 0 input for B input for C• OUT KEYBOARD_CTRL,AL• MOV AL,0FFH ;OFF All Rows• OUT KEYBOARD_ROW,AL • XOR AL,AL ;Reset FIFO • MOV [Key_head],AL• MOV [Key_tail],AL• RET

Page 29: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

INIT_DISPLAY• INIT_DISPLAY:• MOV AL,00001001B ;Mode 0 and out for both A & B. C input• OUT DISPLAY_CTRL,AL• MOV AL,0FFH• OUT DISPLAY_GND,AL ;All 7-Segments off• XOR AX,AX ;Clear ALL Ms of Calc(X,Y,M0-M7)• MOV ES,AX• MOV DI,offset X_SIZE• CLD • MOV CX,10• REP:STOSW ;X_SIZE=Y_SIZE=M_SIZE0-7=0• CALL REFRESH_DISPLAY• RET

Page 30: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

REFRESH_DISPLAY• REFRESH_DISPLAY: ; Shows the content of X register• MOV DI,offset DISPLAY_DATA• MOV AX,[X_SIZE]• CMP AX,0• JNE X_NOT_ZERO• XOR AX,AX• MOV WORD PTR [DI],AX• MOV WORD PTR [DI+2],AX• MOV WORD PTR [DI+4],AX• MOV BYTE PTR [DI+6],AL• MOV BYTE PTR [DI+7],10111111B• RET

Page 31: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

INIT_TIMER• INIT_TIMER:• MOV AL,00110110B ;Counter 0, 2 Bytes, Mode 3, Binary• OUT TIMER_CTRL,AL• MOV AX,36864 ;7.3728M/36864=200Hz; Refreshing Rate• OUT TIMER_CH0,AL• MOV AL,AH• OUT TIMER_CH0,AL • • MOV AL,01110111B ;Counter 1, 2 Bytes, Mode 3, BCD• OUT TIMER_CTRL,AL• MOV AX,200H ;200Hz/200=1Hz; Time Refresh Rate• OUT TIMER_CH1,AL• MOV AL,AH• OUT TIMER_CH1,AL• RET

Page 32: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

INIT_8259

• INIT_8259: • MOV AL,00010011B

;ICW1: Edge - Single - ICW4• OUT IC8259_0,AL• MOV AL,80H ; ICW2=Interupt Type• OUT IC8259_1,AL• MOV AL,00000001B ;ICW4: 8086 Processor• RET

Page 33: A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232

INIT_RS232

• INIT_RS232: