4 M68230 Parallel Interface/Timer Used by M68000 to communicate with external devices.Parallel data transfer.Has three ports:Port A, Port B, Port C.Each port is 8-bits long.Ports connect to devices.Ports need to be initialized before used.
8 Registers in M68230 M68230 contains 23 registers. Each of the registers have a unique address that refers to them.To initialize ports, some registers need to be configured.Port General Control Register.Port X Control Register (A, B).Port X Data Direction Register (A, B, C).Port X Data Register (A, B, C).
9 PGCR Port General Control Register. Used to set the operation of Port A & Port B.You only need to know (and use) Mode 0.MOVE.B #$00,PGCR
10 PGCR Settings PGCR= Description $00 Unidirectional 8-bit transfer (Port A, Port B)Mode$40Unidirectional 16-bit transfer (Port A + Port B)1$80Bidirectional 8-bit transfer onPort B, bit I/O on Port A.2$C0Bidirectional 16-bit transfer (Port A + Port B)3
11 Port X Control Register Used to set buffering of input/output on PXDR.Three modes:Mode 00.Mode 01.Mode 1X.You only need to know (and use) mode 1X.
30 Example 1: Set LED M68230 LED0 A set of LEDs are connected to PB0 Port B in M Write a programthat turns on LED3 and LED4, andturns off the rest.PB0PB1PB2PB3PB4PB5PB6PB7LED1LED2PortAddressPGCR$800001PACR$800005PBCR$800007PADDR$800009PBDDR$80000DPCDDR$80000FPADR$800011PBDR$800013PCDR$800019LED3LED4LED5LED6LED7
31 Discussion Port B should be initialized before being used. To turn on LED, the voltage at Port B bits should be high.To turn off LED, the voltage at Port B should be low.
32 LED Operation A B A B LED Zero biased (OFF) 1 Reverse biased (OFF) 1 Zero biased (OFF)1Reverse biased (OFF)1Forward biased (ON)11Zero biased (OFF)
36 Example 2: Read Switches & Output to LED A set of switches are connected to Port A, and a set of LEDs are connected to Port B in M Write a program that reads the value in the switches and turns on the respective LEDs.
47 7-Segment Consists of 7-LEDs arranged together. Can display numbers and characters.Each segment is marked with a letter (a to g).To display characters, need to turn on/off certain segments.Also has E (enable) pin to turn on/off 7-segment.
48 Interfacing 7-Segment with M68230 To interface with M68230, each segment (a to g) is connected to a port in M68230.The E signal must also be connected to a port to enable/disable the 7-segment.
49 7-Segment Types There are two types of 7-segment displays: Common cathode.Common anode.Each type differs in how they behave with certain inputs.
50 Common Cathode 7-Segment Input (from M68230)EInputOutputOFF1ON1OFF11ON
51 Example: Interfacing CC 7-Segment with M68230 (No Transistor) bcdefgB0B1B2B3B4B5B6B7E(Common cathode)To turn on the 7-segment, E must be set to 0,and the input to be turned on must be set to 1.
52 Example: Interfacing CC 7-Segment with M68230 (With Transistor) B0B1B2B3B4B5B6B7abcdefgEM68230R(Common cathode)To turn on the 7-segment,E must be set to 1,and the input to be turned onmust be set to 1.By setting E to 1, the transistor isturned ON, providing apath to GND.
53 Displaying Numbers: CC7S (No Transistor) fgNumber1XXXXXXXNone11111111211111311114111115111116111711111118111119111111
85 7-Segment + BCD DecoderA BCD 7-Segment decoder can be used to simplify the interface to M68230.Just send a BCD number, and it will be automatically displayed at 7-segment.Also reduces the number of connections required to display 7-segment values.
102 Controlling DC MotorsHas two terminals (positive/negative), connected to DC voltage.If positive voltage applied at positive terminal, motor moves clockwise.If negative voltage applied at positive terminal, motor moves anti-clockwise.
103 DC Motor +12V +12V + - + - + with + = clockwise + with - = anti-clockwise
104 Interfacing DC Motor with M68230 – Single Direction +-M68230A0A1A2A3A4A5A6A7+12VRMOVE.B #$00,PGCRMOVE.B #$80,PACRMOVE.B #$FF,PADDRMOVE.B #$10,PADR
105 Interfacing DC Motor with M68230 (Two Directions) +12VRRRRA0T1T2A2+-RRA1A3T4T3PNP transistors areturned on by 0 at base.NPN transistors areturned on by 1 at base.
106 Moving the Motor Clockwise MOVE.B #$00,PGCRMOVE.B #$80,PACRMOVE.B #$FF,PADDRMOVE.B #% ,PADR(Turn on T1 and T3)
107 Interfacing DC Motor with M68230 (Clockwise) +12VRR1RR1A0T1T2A2+-11RRA1A3T4T3Positive meets positive, clockwise direction
108 Moving the Motor Anti-clockwise MOVE.B #$00,PGCRMOVE.B #$80,PACRMOVE.B #$FF,PADDRMOVE.B #% ,PADR(Turn on T2 and T4)
109 Interfacing DC Motor with M68230 (Anti-clockwise) +12VRR1RR1A0T1T2A2+-11RRA1A3T4T3Positive meets negative, anti-clockwise direction
115 Step 2: Scan 1st ColumnCOL1 BCLR.B #1,PBDRBCLR.B #2,PBDRBSET.B #0,PBDRMOVE.B PBDR,D1AND.B #$F0,D1CMP.B #$10,D1BEQ IS1CMP.B #$20,D1BEQ IS4CMP.B #$40,D1BEQ IS7CMP.B #$80,D1BEQ ISSTARBNE COL2IS1 MOVE.B #1,D0BSR WAITMOVE.B #9,D3TRAP #0BRA COL1IS4 MOVE.B #4,D0BSR WAITMOVE.B #9,D3TRAP #0BRA COL1IS7 MOVE.B #7,D0ISSTAR MOVE.B #$00,D0* MOVE.B #9,D3 and TRAP #0 are used as an example to displaythe output to screen. Replace it with your own code.
130 Delay SubroutineIn some applications, we may need to delay the output before executing next instruction.Can be achieved using delay subroutine:Does some meaningless repetitive task over and over.“Wastes” processing time of M68k.Can be set to repeat until desired delay is achieved.
132 Clock Cycles to Complete Calculating The DelayTo calculate delay, you need to know the time required to execute each instruction:InstructionClock Cycles to CompleteTimeMOVE.L12sSUB.L16sCMP.L14sBNE10sRTS10MHz T = 1/10MHz = 1x10-7secs.Executed n times.
133 Calculating the Delay – M68k 10MHz For 1 sec., 10,000,000 clock cycles are required.10,000,000 = ( )n10,000,000 = nn = (10,000,000 – 28)/40n = (10,000,000 – 28)/40 = 249,999
135 Calculating The Delay – 0.25s To calculate delay, you need to know the time required to execute each instruction:InstructionClock Cycles to CompleteTimeMOVE.L12sSUB.L16sCMP.L14sBNE10sRTS10MHz T = 1/10MHz = 1x10-7secs.Executed n times.
136 Calculating the DelayFor 0.25 sec., 2,500,000 clock cycles are required.2,500,000 = ( )n2,500,000 = nn = (2,500,000 – 28)/40n = (2,500,000 – 28)/40 = 62,499
138 Implementing Delay START ORG $090000 INIT MOVEA.L #$100001,A * base address of pi/tMOVE.B #$80,$E(A6) * configure port B control reg to mode 1xMOVE.B #$FF,$6(A6) * configure port B data reg to o/pLOOP MOVE.B #$FF,$100013BSR DELAYMOVE.B #$00,$100013BRA LOOPDELAY MOVE.L #249999,D7DELLOOP SUB.L #1,D7CMP.L #0,D7BNE DELLOOPRTSEND STARTTurn on all LEDs,Wait 1 second,Turn off all LEDs,Wait 1 second.
140 ConclusionThe M68230 is a parallel interface used by M68k to connect with various devices.The M68230 has three ports, which can be configured to interface with many devices.To use the ports, it MUST be initialized first.
141 ConclusionThe delay subroutine is used to “waste” the CPU’s time by telling it to do repetitive tasks.The delay format is basically the same, just adjust the counter to get the delay you want.
142 The End Please read: Antonakos, pg. 352-366 M68230 Datasheet Ablelogic, Abitec, VTES Manuals