Everyone knows about the popular Zilog Z-80, the Intel 8086, the 6800 cpu, and whatever. People know how to interface these cpu's, program them, and make cool little applications with these. And wait, there's one cpu family that doesn't stand out between these popular hobbyist cpu's, and that's the 8041, or 8042. Not many sites on the net present a solution on how to interface external memory, control I/O's, or even program these cpu's. The challenge of this website is to do just the above, and whatever bullshit that needs to be done.
The 8041 and 8042 did have one application in their times, and that was to interface the PS/2 keyboard protocol to the IBM computer. Many places the 8042 are found are on old 8036, 80486 motherboards =). These cpu's can also be called "slave" microcontrollers. AMD, Intel, NEC, and Mitsubishi manufactured these chips (there could be other manufacturers, but I guess I don't have these chips ;o!).
2) CPU Overview
8041 cpu
8042 cpu
Speed
6 MHz
12.5 MHz
Internal OTP ROM Space
1024 bytes
2048 bytes
RAM
128 bytes
256 bytes
Features
8-Bit CPU
8-Bit Data Bus Interface Registers
Interval Timer/Event Counter
Two 8-bit TTL Compatable I/O Ports
Resident Clock Oscillator Circuits
External Memory Access using Data Register + I/O Ports
Single Step Input
Resident Clock Oscillator Circuits
Two Test/Input bits (Taking the chip to 16 Inputs/Outputs + 2 Inputs)
3) CPU Pinouts
Pin 1 (I) = TEST 0: An input pin that can be directly tested using conditional branch instructions in software.
Pin 2 (I) = XTAL 1: Crystal Oscillator input. Can be connected to ground if clock is being driven from an external source.
Pin 3 (I) = XTAL 2: Crystal Oscillator input. Can be connected to clock if being driven from an external source.
Pin 4 (I) = !RESET: Resets the microcontroller when pulled low. Pull high when microcontroller wants to run
Pin 5 (I) = !SS: The microcontroller's single step input. Pull to +5V when not used.
Pin 6 (I) = !CS: Chip Select Input used for data register port interfacing. Active low, pull to +5V if not used.
Pin 7 (I) = EA: External Access Input will disable the internal OTP ROM, and enable instructions to be fed into the microcontroller externally. Bring to GND if not used, VCC if enabled.
Pin 8 (I) = !RD: Output Enable Input, used for data register port interfacing. Active low, pull to +5V if not used.
Pin 9 (I) = A0: Command/Data Register Select Input, used for data register port interfacing. Don't leave unconected.
Pin 10 (I) = !WR: Write Enable Input, used for data register port interfacing. Active low, pull to +5V if not used.
Pin 11 (O) = SYNC: Output Clock signal that occurs once for every instruction. This pin can be used to strobe external I/O's.
Pin 12-19 (I/O) = D0-D7: Data bus, used for data regsiter port interfacing. If external access is enabled, then memory data should be present on these lines when SYNC is low.
Pin 21-24 (I/O) = P20-P23: General Purpose I/O Port #2, bits 0-3. Also acts as addresses 8-10 (P20-P22) when external access is used.
Pin 25 (I/O) = PROG: During I/O expander access, this pin acts as an address/data strobe to the 8243. This pin should be tied high if unused.
Pin 26 = VDD: +5V Power Potential
Pin 27-34 (I/O) = P10-P17: General Purpose I/O Port #1, bits 0-7. Also acts as addresses 0-7 (P10-P17) when external access is used.
Pin 35-38 (I/O) = P24-P27: General Purpose I/O Port #2, bits 4-7. Can be programmed to provide Interrupt Request and DMA Handshake capability.
Pin 39 (I) = TEST 1: An input pin that can be directly tested using conditional branch instructions in software. Also serves as the event timer input controlled by software.
Pin 40 = VCC: +5V Power Potential
Note: All inputs need to be connected in some way! (even pin PROG)
4) External Access Connections
Why use external access while there's an internal OTP ROM? The OTP ROM can only be programmed once, meaning after being programmed, it can't be programmed again. Also, many 8042 microcontrollers pulled from 80x86 motherboards are already programmed with the keyboard interface firmware. Trying to buy a blank 8042 isn't easy either.
External access mode is initialized when pin 7 (EA) is tied to VCC. On the trailing edge (going from HI to LOW) of SYNC (pin 11), the program counter contents are present on ports P10-P17 and P20-P22 (going to memory A0-A10). Using SYNC as a chip enable for memory is okay (SYNC low = chip enabled) as long as data is presented on the data bus on time for the S1 state. On the rising edge of SYNC (going from LOW to HI), port data can be strobed from/to P10-P17 and P20-P22.
For strobing outputs on P10-P17, or P20-P22:
Use a 74LS374 or equivalent flip-flop to output the data (equivalent flip-flop as in data is strobed on the rising edge of the clock. A 74LS373 won't work).
* 8042/8041 SYNC => Enable/Clock input (pin 11) of 74LS374
* 8042/8041 P10-P17 or P20-P22 => Data inputs (pins 2-9) of 74LS374
* GND Potential => Output Enable (pin 1) of 74LS374
* Data is presented on Q outputs of flip-flop (pins 12-19) of 74LS374
5) Programming + Datasheets
I won't go over programming. Just find yourself the microcontroller datasheet to use as a reference for programming. The 8042 and 8041 is code compatable with the 8048, except that there are no external program memory instructions, and that data bus register instructions have been added. There's only one assembler that I know of, that will compile for 8042 or 8041 and that's SB Assembler. A modified 8048 TASM table could also be made.
There's not much to the 8042 and 8041. The microcontrollers were designed to not use external program memory, but in fact does have limited implementations of it (only for reading instruction data).
The fastest I could overclock an 8042 was 40.0000 MHz while running stably. The manufacturer of the chip was Intel. Other chipsets like NEC and Mitsubishi couldn't clock this high.
Created by DevSter, aKa Joseph Norman
Visit the author's homepage at http://devster.monkeeh.com/
Last updated: 4/Aug/2005 21:30