You are on page 1of 44

T89C51 Training Board Manual

T89C51 Training Board


T89C51 Training Board.doc Page 1/44

T89C51 Training Board Manual

1.0 Introduction

Training boards allow a quick implementation of a software program design and successive downloads
of the program directly in circuit without the need to remove the microcontroller and place it in a
programmer. This enables the software to be tested quickly and necessary modifications made easily,
improving the project and product development times considerably. This board can also be used in a
more fixed application, as a base or CPU board for a more complex system. Connections are provided
to each of the microcontroller pins, and these connections can then be run to a auxiliary board, where
all the other IC’s are mounted to interface to the outside application. This allows easy swapping of the
boards, if necessary and also the auxiliary board to be changed easily without affecting the main board.

The T89C51 Training Board uses the T89C51 as a base microcontroller. This IC is one of the newer 80
series devices from Atmel, offering much larger program space and a range of peripherals to suit a
number of applications. The T89C51 includes a large 32kb of program flash memory, together with a
large RAM for storing temporary variables. A large 2k EEPROM is also included for retaining preset
values while the power is disconnected. A 2k Flash Bootloader, is also included to allow the device to
be programmed using a standard RS232 connection, a special programmer is not required when
programming the microcontroller using this feature.

The T89C51 also includes a number of peripheral features which reduce the need for special auxiliary
IC’s. In particular the 5 channels of Pulse Width Modulation, enable this microcontroller to be used in
a number of motor control functions, including standard motor control, together with robotic
applications. A total of 8 channels of Analog to Digital converters are also provided, with 10 bit
accuracy for each. This is ideal for an analogue system, where a large number of sensors are used.
These could also be used as feedback sensors in the motor control application discussed earlier.
Similarly a UART is provided for connecting to a PC, allowing information transfer between the PC
and development board. This UART also enables multiprocessor communication, allowing a number of
boards to be connected together, with information passing between each. This would allow a more
complex system, with a series of boards working together to monitor and control the equipment.

Figure 1: T89C51 Training Board

T89C51 Training Board.doc Page 2/44

T89C51 Training Board Manual

Chapter 2 - Specifications

2.1 Board Specifications

Summary of board specifications and features

• T89C51 on-board with 18.432MHz Crystal

- 32Kbytes of Flash Memory
- 256 bytes of RAM Memory
- 1Kbyte of ERAM
- 2 Kbytes of EEPROM Memory
- 32 + 2 Digital I/O pins
- 3 16-bit Timers
- 5 Channel 16-bit PCA with
- PWM (8-bit)
- High-Speed Output
- Timer and Edge capture
- 8 channels ADC with 10-bit accuracy
- SPI Serial Interface
• In circuit programming via computer download cable (provided)
• 5V regulator on-board with necessary power supply components
• 34 Pin I/O connector for access to microcontroller port pins
• Separate PWM Connectors
• Adjustable Analogue Reference Trimpot
• RS232 Communication with on-board MAX232 or equivalent
• Real Time Clock (PCF8583)
• EEPROM (24LCXX Series)
• I/O Expansion IC (PCF8574)
• Buzzer On-Board
• LCD Connector and Contrast Trimpot Pre-installed
• RS422 / RS485 Communication
• Magnetic Card Reader Supported
• Relay Socket
• Keypad Connector
• I2C Bus Expansion Socket
• Test LED
• Power-On LED
• PSEN pushbutton
• RESET pushbutton provided

T89C51 Training Board.doc Page 3/44

T89C51 Training Board Manual

2.2 Microcontroller Specifications

The T89C51 includes a lot of new exciting features, beyond that of the previous 80 series
microcontrollers. These include,

Self-programming In-System Programmable Flash Memory:

• 32K Bytes with 2K bytes Boot Block

Endurance – 10,000 Write / Erase Cycles
• 2K Bytes EEPROM
Endurance – 100,000 Write / Erase Cycles
• 256 Bytes Internal SRAM
• 1K Byte On-Chip ERAM
• Programming Lock for Software Security

Peripheral Features:

• Three 16-bit Timer/Counters

• Five Ports: 32 + 2 Digital I/O Lines
• Five Channel 16-bit PCA with:
- PWM (8-Bit)
- High Speed Output
- Timer and Edge Capture
• 8-channel, 10-bit Analog to Digital Converter
• Full Duplex UART Compatible 80C51

Special Microcontroller Features:

• On-Chip Emulation Logic

• Double Data Pointer
• 21-bit Watchdog Timer
• Power Saving Modes: Idle Mode and Power-Down
• 14-sources, 4-level Interrupts

Power Consumption at 8MHz, 5.5V and 25oC:

• Active 8.6mA
• Idle Mode 6.8mA
• Power-down Mode <160 µA

T89C51 Training Board.doc Page 4/44

T89C51 Training Board Manual

Fig. 2 – T89C51 Pinout

Fig. 3 – T89C51 Block Diagram

2.3 80 Series Microcontrollers

The 80 Series was first released by Intel in the1980’s, and is now the most common
microcontroller series available. Many companies produce equivalents or upgraded versions
of the 8051 microcontroller, these include Dallas semiconductor, Philips and Atmel. Also
there are a large number of compilers available to produce code for the 80 series. Basic, C,
Fortran, and assembly language compilers are all available to produce hex formatted output
files suitable to load into this microcontroller.

T89C51 Training Board.doc Page 5/44

T89C51 Training Board Manual

Chapter 3 - Set-Up and Programming The Training Board

3.1 Setting Up

Firstly connect the T89C51 Development Board to a suitable DC power supply. This should
be between 9-12Vdc and capable of at least 500mA. The jack can be either positive-negative
or negative-positive. Once the power supply is connected the red Vcc LED will illuminate.

Next connect the computer cable (ET-DOWNLOAD), that is included with the development
board. The 9 pin DB 9 connector is connected to the computer serial (RS232) port.

Figure 4: ET-Download cable

The 5 pin polarized connector, is connected to the development board, at the white socket
(ET-DOWNLOAD) located at the bottom of the board. This connector will only go in, in a
single direction, the locking piece needs to match the white back in the polarized male header,
as seen below.

Figure 5: Download Cable Connection

The board is now ready to program.

T89C51 Training Board.doc Page 6/44

T89C51 Training Board Manual

3.2 Preparing Software

To download a program to the T89C51 board, it will be necessary to prepare and compile a
suitable program, by using any of the many development tools that are available for this
microcontroller. The compiled program needs to be in *.hex format prior to downloading.

A basic compiler is included with the accompanying CD. To prepare a sample program,
follow these steps. It will first be necessary to prepare the code using a basic text editor such
as Windows Notepad. When this is complete, save the file as xxxx.asm. Then go to MS-Dos
and run the Sxa51.exe program with the assembly file specified, i.e.

C:> Sxa51 test.asm

A number of options are available, as can be seen when running the program. Once the
program is complete and there are no errors a hex file will be produced such as test.hex, which
is then ready for downloading.

3.3 Downloading to the Board

Atmel have made available an easy to use download program for Windows and Linux. This
program is available from the Atmel website, we have also included a copy on the
accompanying CD. The Atmel FLIP (Flexible In-System Programmer) allows easy set-up of
the computer and necessary parameters for downloading the compiled program to the target

3.3a – Installing Atmel FLIP

Two versions of Atmel FLIP are included in the accompanying CD. Firstly FLIP for
Windows, which is suitable for Windows 95,98, Me, NT and 2000. Secondly FLIP for Linux.
To install either version is quite straightforward.

1. Either download the contents of the ZIP file to a temporary directory and click Setup. Or
double click on Setup.exe from within the WinZIP archive.
2. The program will then commence installation.
3. You will be required to accept the licence agreement by pressing ‘Yes’.
4. Then you have the option to specify the directory where the program will be installed, or
to accept the default directory of Program Files\Atmel
5. When the installation is complete a final Window will appear, with a Finish button to
complete the process.
6. To run Atmel Flip, simply double click on the ‘FLIP 1.8.2’ icon in the program directory,
or select ‘FLIP 1.8.2’ from the Atmel section in the program browser.

3.3b – Downloading a program to the T89C51 Development Board

Using Atmel FLIP

To down-load the compiled software to the board.

1. Connect the RS232 (ET-DOWNLOAD) connector between the computer and the T89C51
Development Board. The socket on the board is marked ET-DOWNLOAD.

2. Connect a power supply, 9-12Vdc to the power connector on the board. The red ‘Power’
LED should now illuminate.

3. Open or Run the Atmel FLIP program, this should already be installed on your computer,
as per section 3.3a.

T89C51 Training Board.doc Page 7/44

T89C51 Training Board Manual

4. On the Atmel FLIP program, click on the Device Menu and go to Select, a number of
devices will now appear. Select the device ‘T89C51AC2’

T89C51 Training Board.doc Page 8/44

T89C51 Training Board Manual

5. Now place the T89C51 Development board in Monitor mode for program download, this
is done by pressing the PSEN and RESET buttons in the following sequence

a. Press and hold the PSEN pushbutton on the development board.

b. Now Press the RESET pushbutton on the development board, while
still holding the PSEN pushbutton
c. Release the RESET pushbutton
d. Now release the PSEN pushbutton

This will place the board in Monitor mode for program download.



6. On the Atmel FLIP program, click on the settings menu, and select communication
RS232. Then select the appropriate communication port you are using, either COM1 or
COM2. Then select the speed at 115200 and press the ‘Connect’ button, at the bottom left
of this dialogue window. The FLIP program will now communicate with the T89C51, to
receive the various identification information and preset settings. This will appear in the
device section of the program.

T89C51 Training Board.doc Page 9/44

T89C51 Training Board Manual

7. Now load the Hex file that is to be downloaded to the board, by clicking on the File Menu
and then ‘Load Hex’. The Hex file will then be loaded in the program buffer, ready for
download to the device. Once the hex file has been loaded the information will appear on
the program in the buffer information section.

8. Now select the Operations Flow required. To program the device, we should select, Erase,
Blank Check, Program and Verify. With these selected, now press the Run button at the
bottom of the Operations Flow Section.

T89C51 Training Board.doc Page 10/44

T89C51 Training Board Manual

9. As the program is being loaded, the progress bar will indicate the amount of the memory
that has been programmed. When the progress bar is 100%, and message will appear
indicating the programming is complete.

10. Now reset the CPU, by pressing the RESET button on the T89C51 development board.
The downloaded program will now run on the T89C51 Development Board.

3.4 Using the Software

Operation of the software is quite straightforward. A detailed manual is also included in pdf

Format, within the Atmel/Flip1.8.2/Doc directory. This details operation, configuration and
troubleshooting for the FLIP program. The Help command is also available from within the
program, to allow easy access to the relevant sections of the Help Manual.

A configuration file can also be built for use when a number of devices are going to be
programmed with identical parameters and hex file. This file can be built using FLIP or with a
text file editor. Once the file is prepared, all that is required is to click on File and Load
Configuration, the appropriate device is then selected, the communication port, speed and
protocol is set. The hex file is loaded and the device programmed. Examples of how to
prepare configuration files and a sample configuration file is included in the pdf manual.

T89C51 Training Board.doc Page 11/44

T89C51 Training Board Manual

3.5 Running My First Program – test_led.hex

A number of programs are included with the accompanying CD, that will demonstrate the
features of the board, and provide a number of ready to run solutions to test various parts of
the board. In this section we will load and run the Led program, to flash the test LED at port
position P2.6. This is the green test LED, that is located just to the left of the T89C51.

Firstly connect the board to the computer and power supply as indicated previously. Also
ensure the jumper is in place next to this LED, which connects the LED to port pin P2.6.

Fig 6 – Test LED and Power LED

Then open the download software (FLIP), which should be installed on your computer. Now follow the
steps as below,

1. Click on the Device Menu and press ‘Select’, now choose ‘T89C51AC2’ from the drop
down menu.
2. Now place the T89C51 Development board in Monitor Mode by

a. Press and hold the PSEN pushbutton on the development board.

b. Now Press the RESET pushbutton on the development board, while
still holding the PSEN pushbutton
c. Release the RESET pushbutton
d. Now release the PSEN pushbutton

3. Then click on the Settings Menu and select Communications – RS232. There are now two
buttons, firstly the COMPORT button, for you to select either COM1 or COM2
depending on which serial port is being used for the connection to the T89C51
Development Board. The press the BAUDRATE button, to select a speed of 115200.

T89C51 Training Board.doc Page 12/44

T89C51 Training Board Manual

Once this selection is complete, press the Connect button. If the connection is successful,
a message will then appear in the bottom right of the program, indicating the COM port
and the speed specified. Also the T89C51 default data will appear in the device section of
the program.

If the connection timed out or a error message appeared. Check the power and RS232
connection cables, that they are in place correctly and that the Red LED is illuminated on
the board. If this is okay, reset the board and follow step 2 again, to place the board in
Monitor Mode.

4. The next step is to load the hex file in the buffer. To do this, click on the File menu and
Load Hex. Use the file browser to locate the program ‘test_led.hex’, which is located in
the examples section of the CD. Then press Load, as the program is being loaded the
progress bar at the bottom of the program window will display the percentage complete.
Once the download is complete, the Buffer Information section will display the relevant
file data.

5. Now select, Erase, Blank Check, Program and Verify from the Operations Flow section
of the FLIP program. Once these are selected press the Run button.
6. The program will now be downloaded into the T89C51 microcontroller, once this is
complete a message will appear on the program, indicating the programming and verify
operation is complete.

7. The program can now be started, by pressing the ‘RESET’ button on the T89C51
Development Board.

3.6 Troubleshooting

Program Downloads But Will Not Run

1. Verify your code, has been downloaded correctly, by selecting Verify in the operations
flow and press the Run button.
2. Check your code or use a compiled program that is known to work.

Program Will Not Download

1. Check cable connections and power supply.

2. Check port selection on the programming software, is correct according to the serial port
being used.
3. Check T89C51 is in Monitor Mode prior to downloading of the software.

T89C51 Training Board.doc Page 13/44

T89C51 Training Board Manual

Chapter 4 – Port 0 to Port 4

4.1 Introduction

The T89C51RD2 microcontroller has 4 ports for general I/O use. These consist of the following,

Port 0 – Identified as P0.0 to P0.7 – 8 Port Pins

Port 1 – Identified as P1.0 to P1.7 – 8 Port Pins
Port 2 – Identified as P2.0 to P2.7 – 8 Port Pins
Port 3 – Identified as P3.0 to P3.7 – 8 Port Pins
Port 4 – Identified as P4.0 to P4.1 – 2 Port Pins

These ports also have a number of ancillary functions, which can be selected by setting the various
registers. These will be explained in greater detail in later section.

4.2 Port 1, Port 3 and Port 4

Ports 1,3 and 4 on the T89C51RD2 all have internal pull-ups and each of these pins can be configured
as general purpose I/O or for their alternate function. To use the pin for general purpose I/O set or
clear the corresponding bit in the Px register of the port concerned. To use the port pin as an input the
pin needs to be set to a 1 in this Px register. In the case of using the alternate port functions, this bit in
the Px register also needs to be set to a 1.

Port 1 on the T89C51RD2, is also used for ADC and PWM. These port pins have also been wired to
the ADC connector on the board and also the PWM connectors. For more information refer to the
schematic and the relevant chapter in this manual.

Port 3 also serves a number of other functions. Port pins 3.0 and Port 3.1 are for the on-chip UART,
and have been wired to the MAX232 as well as the RS422/Rs485 circuits on the board. The remaining
pins P3.2 to P3.7 have been connected to the 34 pin connector as well as a number of other functions.
P3.3 is used on the magnetic card reader connector, P3.4 for the RS422/RS485 circuit, to control
sending and receiving of data with RS485. P3.5 is also connected to the relay coil, for switching of the
relay. P3.6 is used with the magnetic card reader circuit, for the data input/output. P3.7 for the clock
signal with the magnetic card reader.

Port 4 pins are wired for the I2C bus, with P4.0 as the clock line and P4.1 as the data line.

The internal arrangement within the microcontroller for these port pins is shown below.

T89C51 Training Board.doc Page 14/44

T89C51 Training Board Manual

4.2 Port 0 and Port 2

Port 0 and 2 differ from the above ports, in that they do not have internal pull-ups. These ports can be
used for general purpose I/O also or alternatively as the data/address bus in a microcomputer system.
To use the various pins as I/O, again set the appropriate pin in the Px register to a 1 or a 0. For an input,
set the Px register bit to a 1.

On the T89C51 Training Board, the Port 0 is connected directly to the 34 pin connector as well as KBI,
the keypad input connector. For P0.7 this is also connected to the speaker. To select the speaker it is
necessary to place the jumper on the speaker side, and for the keypad to place the jumper at the “4x4”
markings, on the board.

For Port 2, these pins are connected directly with the 34 pin connector as well as the LCD. For using
an LCD, the connections from the T89C51 are as follows,

P2.0 - D4 for LCD Data

P2.1 - D5 for LCD Data
P2.2 - D6 for LCD Data
P2.3 - D7 for LCD Data
P2.4 - EN for LCD signal
P2.5 - RS for LCD signal

T89C51 Training Board.doc Page 15/44

T89C51 Training Board Manual

Chapter 5 – 34 Pin 72IOZ80 Connector

5.1 Introduction

All port pins are conveniently brought out to this 34 pin connector, together with the GND and Vcc
connections. The configuration of the pins can be seen in the below diagram. A standard 34 pin IDCC
connector can be used to connect to this socket, these are available on the Futurlec website,

This connection is ideal when another board is used as an interface board or as a connection to more
complex circuitry. In this case the T89C51 Board can be used as a main processor board, and
connected to ancillary boards as required. The ancillary board can then easily be changed and modified
away from the main board, and a simple plug connection is all that is required to separate the boards.

Fig 7 - Diagram of 34 Pin IO Connector

T89C51 Training Board.doc Page 16/44

T89C51 Training Board Manual

Diagram 1 – 34 pin Connector

T89C51 Training Board.doc Page 17/44

T89C51 Training Board Manual

Chapter 6 – Keypad Connector

6.1 Introduction

A keypad connection has been provided at P0 (KBI) Connector, this can be used with standard 4x4 or
4x3 matrix keypads. Sample programs are provided on the accompanying CD. For sensing, one side of
the matrix can be raised to a high, and the bottom outputs, monitored or scanned for a high signal,
indicating a key has been pressed. Once a press is detected, each side input signal can be alternatively
raised and lowered to detect which key has been pressed. By following the sample program a better
understanding of this operation can be deduced.

A standard 10 pin IDCC connector can be used to connect to this socket, the wired accordingly to the
keypad signals. A diagram of the connection of the keypad is seen below,

Fig. 8 - Keypad Connector

Diagram 2 – Keypad Connector

T89C51 Training Board.doc Page 18/44

T89C51 Training Board Manual

Chapter 7 – ADC Connector

7.1 Introduction

The PORT1 ADC port pins are all brought out to the ADC socket for ease of connection to monitoring
equipment. It is always good practice to separate the analog signals/circuit from the digital circuit. Thus
these connections can then be taken to a separate board or circuit area for isolation of the inputs. These
port 1 pins also have dual functions and it is necessary to select the ADC operation prior to using the
inputs. By setting the various bits within the ADCF register of the T89C51, we can select which pins
are to be used for ADC and which can be used for standard I/O.

To perform an A/D conversion, first select the port pin the conversion is to take place on. This is done
by setting the SCH0 to SCH2 bits, within the ADCON register. Refer to Table 56 of the technical data
sheet. An actual A/D conversion on the selected pin, is triggered by setting the ADSST bit. This is
located within the ADCON register. When the conversion is complete, this bit will be cleared by the
microcontroller. An easier way to monitor the completion of the conversion is to use the end of
conversion flag, ADEOC, in the ADCON register. When this flag is set the value is available at the
ADDH and ADDL registers.

When the input signal is equal to the A/D reference voltage VAREF, the result will be 3FFh. For a
value between the VAGND ground reference voltage and the VAREF high reference. The result will
be a linear conversion between these upper and lower limits. It is important to ensure the input voltage
does not exceed, the VAREF voltage, as this may lead to damage of the IC.

The arrangement of the ADC connection can be seen below.

Fig 9 – Diagram ADC Connector

T89C51 Training Board.doc Page 19/44

T89C51 Training Board Manual

Diagram 3 – ADC Connector

T89C51 Training Board.doc Page 20/44

T89C51 Training Board Manual

Chapter 8 – I2C Connector

8.1 Introduction

The connections from the PCF8574A are available on the IDCC Connector. The layout of this
connection is as show below.

Diagram 3 – I2C Bus Socket

8.2 I2C Bus Expand

A further I2C connector is provided for expansion of the I2C bus. This bus can then be taken from this
board and connected to another board, to allow other devices to be connected to this bus. It is important
to remember the connection should not be too long, as this can affect the operation of the bus. Also
other devices connected to the bus, will require different addresses to those devices already on the bus.
For more information regarding the I2C bus, refer either to the T89C51 data sheet or to Philips
Semiconductor, who were the original designers of this bus concept, a number of information data
sheets are available on the Philips website.

Diagram 4 – I2C Bus Expansion Socket

T89C51 Training Board.doc Page 21/44

T89C51 Training Board Manual

Fig 10 - Diagram of I2C Bus expand Connector

T89C51 Training Board.doc Page 22/44

T89C51 Training Board Manual

Chapter 9 – Magnetic Card Reader

9.1 Introduction

The T89C51 Training Board is designed to work directly with the MCR-B02TTL Magnetic card
reader. The connector from this device, can be plugged directly into the T89C51 board. This is an ideal
starting point for a restricted area access system, or employee identification logging system. The data
from the card, will be passed to the board, which can then log the information or pass it via the board’s
RS232 connection to a computer, for card identification, recording and enabling access to the area as
required. A electronic latch could be connected to one of the port pins, to open a door or gate, once
access is authorised.

Several software examples are provided on the CD. There are two ways to work with this card, the first
one, is to constantly monitor the output of the card reader, to identify as soon as a card is present.
Alternatively the INT1 jumper can be connected on the board, this will connect the card reader
PRESENT signal to the INTERRUPT input of the microcontroller. A present signal will then generate
an interrupt within the microcontroller, which can then perform an interrupt routine to read the card and
process the data accordingly.

Diagram 5 – Magnetic Card Reader Connector

Figure 11 – Magnetic Card Reader

T89C51 Training Board.doc Page 23/44

T89C51 Training Board Manual

Chapter 10 – Output Relay

10.1 Introduction

An output relay is provided on the board, for the control and switching of various devices. The coil of
the relay is connected via a transistor to port pin P3.5. Although the relay output is rated for mains
voltage, we do not recommend any voltage greater than 24Vdc be connected to the output. If it is
required to switch mains appliances, the relay output could be used to switch a triac or other device,
that was suitably isolated from the mains voltage, to switch the device.

To use the relay, the jumper relay needs to be connected. This will connect the port3.5 pin to the relay
circuit. By setting this pin to 1, the relay will switch on or close. By setting the pin to 0, the relay will
open or switch off. This pin needs to be set as an output also for the circuit to work.

Note: Port pin 3.5 is also connected to the 34 pin connector, these pins cannot be used simultaneously.
So if Port pin 3.5 is required at the 35 pin IDC connector, it will be necessary to open the jumper at the
relay circuit.

Fig 11 - Diagram of Relay Connector

Pin 1 – Normally Open

Pin 2 – Common
Pin 3 – Normally Closed

T89C51 Training Board.doc Page 24/44

T89C51 Training Board Manual

Chapter 11 – Buzzer

11.1 Introduction

The on-board buzzer/speaker is an ideal warning device, for a dangerous or attention signal. The buzzer
is connected via an interface transistor to port pin P0.7. By selecting this pin as an output, the buzzer
can be turned on or off, by setting the pin to a 1 or 0. To operate the buzzer it is also necessary that the
jumper at 4X4/SPK is set to the speaker position to connect the port pin to the buzzer.

Fig 12 – Jumper Selector for Keypad or Speaker

Note: The port pin P0.7 is also connected to the 34 pin IDCC connector. If the port pin is required at
this connector, it is necessary to disconnect the jumper for the buzzer. The port pin cannot work
simultaneously with the 34 pin connector and the buzzer. It is also possible to connect another port pin
to the buzzer, by connecting between the port pin and the buzzer input.

T89C51 Training Board.doc Page 25/44

T89C51 Training Board Manual

Chapter 12 – LCD

12.1 Introduction

The T89C52 Training Board is designed to connect directly with a standard character based LCD. This
can be of any size from 16x1 to 40x4. A 14 pin IDCC socket is provided on the board, together with a
contrast adjustment trimpot for adjusting the brightness of the display. The data transfer to the LCD is
set up for 4-Bit transfer thus reducing the number of I/O pins used for connecting to the LCD.

Fig 13 – LCD Connection and Contrast Trimpot

12.2 Connecting to an LCD

For the LCD connection a 14 pin IDCC connector is provided on the training board, this is configured
as below.

T89C51 Training Board.doc Page 26/44

T89C51 Training Board Manual

Diagram 7 – LCD Connector

To connect to the board, a 14 pin IDCC connector will be needed together with some ribbon cable. The
grey ribbon cable available from Futurlec is ideal for this purpose. Place the end of the cable in the
IDCC connector and crimp accordingly.

For the LCD connection, there are basically two types of connections available on LCD’s currently.
These are either a single row of 16 connections on the top or bottom of the display. Or a double row on
either side of the display. Connection to either type will now be explained separately,

Single Row: Here is will be necessary to cross each pairs of the wires. Thus in the case of wire 2, this
will run to LCD connection 1, and wire 1 will run to LCD connection 2. Then wire 4 will run to LCD
connection 3, and so on. This can be seen in the diagram below. Take special care, the connection is
started at pin 1, not at pin 14 or pin 16 of the LCD.

Diagram 8 - LCD Connection

T89C51 Training Board.doc Page 27/44

T89C51 Training Board Manual

Double Row: For the double row, this can sometimes be easier depending on the position of the holes.
In some cases it is possible to mount a male IDCC socket on the back of the LCD, thus allowing a
simple cable connection between the board and LCD. In most cases, though it will be necessary to wire
directly to the LCD. As per the above diagram, take care to ensure the correct connections are made to
the LCD, as it can be very difficult to rewire this connection.

Note: In the case of a backlit LCD, if the backlight is required, it will be necessary to run a separate
+5V and ground supply to the backlight. The backlight is connected to pin 15 and 16 of the LCD.

12.2 Running the LCD

A number of sample programs have been included on the accompanying CD for running an LCD
routine. Basically, it will be necessary to first set-up the LCD, by following a pre-determined sequence
for initialisation. After this is complete, data can then be sent to the LCD. It is recommended a data
area be allocated in the T89C51 microcontroller, for the LCD. The values to appear on the LCD can
then be written to this area. The download process to the LCD, will then simply transfer the contents of
this area to the LCD. The size of the data area, should be identical to the number of characters available
on the LCD.

Important: Use the contrast adjustment first for the LCD, such that the dots of the LCD are visible. This
is a common source of errors, as the characters on the LCD will not be seen unless the contrast
adjustment is set correctly.

T89C51 Training Board.doc Page 28/44

T89C51 Training Board Manual

Chapter 13 – I2C Bus

13.1 Introduction

The T89C51 Training Board has a pre-installed I2C bus for communication with a number of devices.
The I2C bus was originally developed by Philips Semiconductor as an easy means to connect with
different devices on a single bus connection by using a simple 2 wire bus. Today there are a number of
manufacturers producing products that comply with this bus specification and can be connected onto
this bus. Also many microcontroller manufacturers, incorporate a master receiver as a special feature
within the microcontroller to control and send data using this bus. On the T89C51 Training board, there
are 3 devices connected to the I2C bus, this is the Real Time Clock, a PCF8583 from Philips. A
EEPROM IC, which can be any device from the 24LCXX range. As well as a special I/O device, the
PCF8574 from Philips. Each of these devices have a different address, which is used when sending or
receiving data, thus allowing the microcontroller to act as a master and identify each device. For the
microcontroller, Pin P4.1 is used as the data line (SDA) and P4.0 as the clock line (SCL). Operation
and message transmission will be covered in a later section.

13.2 Basics

The T89C51RD2 microcontroller does not have dedicated hardware internally to control the I2C Bus,
thus it is necessary to implement this in software and use 2 I/O pins for this bus. On the board the pin
P4.1 is used as the SDA line or data line for sending and receiving data. When data is to be sent the pin
is set as an output pin and when it is necessary to receive or read incoming data, the pin is set to an
input. For the SCL line, this is slightly different as the microcontroller will act as a master and issue all
the clock signals, to which the various devices will respond. Thus this pin is set as an output pin.

The I2C bus floats or is pulled to +5V by 2 pull-up resistors on each bus. When a message is to be
transmitted the data line (SDA) is first pulled low, followed by the clock line (SCL). Transfers are
made with 9 bit words, this consists of an 8 bit data work and 1 bit acknowledge, which is issued by the
receiver. A typical message sent on the bus, consists of firstly the start condition. Followed by the
address of the device to which the message is to be sent, this address is 7 bits in length, an additional
bit, the 8th bit, is used to indicate whether this is to be a read or a write. The receiving device will then
acknowledge receipt of the message. The address of the read or write is then sent as an 8 bit address.

The following data will depend on whether this is to be a read or a write. In the case of a write, the data
is sent one byte at a time until a stop condition is issued or detected. The receiver can stop the
transmission, by failing to acknowledge the byte. In the case of a read, the microcontroller will first
send a start condition, followed by the receivers address, and then the receiving device will place the
data on the bus that was requested from the master. The master will now acknowledge receipt of each
byte. This can be seen in more detail in the diagram below.

T89C51 Training Board.doc Page 29/44

T89C51 Training Board Manual

Diagram 9 – I2C Bus Communication

13.3 Using The Interrupts from the I2C Bus IC’s

To use the interrupt signals from the various I2C devices, it is necessary to connect these to the INT0
pin on the microcontoller. It is possible to connect from 3 sources to the INT0 pin. These are

a) Connect an interrupt signal to INT0 (P3.2) on the 34 pin Connector

b) Connect from the RTC (PCF8583) pin 7 to the INT0 pin
c) Connect from the I/O Port IC (PCF8574) pin 13 to the INT0 pin

Only one of these sources can be used at one time. To connect either of the INT signals from the I2C
bus devices, the I/O Port IC or the RTC, it is necessary to connect the jumper on the board. To connect
the RTC INT signal, place a jumper at the RTC to INT0 header pins. These are located at the top right
of the board. Similarly to connect the I/O interrupt to the microcontroller interrupt, connect the jumper
between the I/O pin and the INT0 pin. This can be seen in the photo below. Do not connect both the
RTC and I/O simultaneously.

Fig 14 – INT0 Connector for Microcontroller Interrupt

T89C51 Training Board.doc Page 30/44

T89C51 Training Board Manual

13.4 Adding Additional Devices to the I2C Bus

Provision has been made on the board to expand the I2C bus, onto another series of devices or another
board. A couple of precautions are necessary if this is to be implemented. Firstly it is necessary to
ensure the devices added to the bus do not have the same address as the devices already on the bus. In
the case of some IC’s it is not possible to change the address, however for others, this address can be
modified by connection to the various address input pins of the device, for example the 24 series
eeproms. Similarly for the PCF8574 I/O IC, up to 8 devices can be connected on the same bus, by
adjusting the address of each.

Secondly, the amount of current consumption needs to be considered, as the microcontroller I/O pin
can only supply or source up to 15mA. If there are a large number of devices, each consuming a small
amount of current, the signal will become degraded, and it will not be possible to recognise clearly the
signals on the bus.

Fig 15 – I2C Bus Expansion Socket

T89C51 Training Board.doc Page 31/44

T89C51 Training Board Manual

13.5 Real Time Clock (PCF8583)

The PCF8583 real time clock from Philips Semiconductor is a flexible I2C bus clock/calender IC. The
IC features many useful functions including standard 12hour or 24 hour clock. Alarm function, with
programmable alarm. Free RAM for use as a scratchpad for storing of parameters. The IC can also be
used as an event counter, which will count the number of input pulses and sound an alarm when the
number of the count, matches the alarm value stored within the IC.

Fig 16 – Real Time Clock IC Socket and Crystal

Fig 17 – Battery Back-Up For Real Time Clock

T89C51 Training Board.doc Page 32/44

T89C51 Training Board Manual

Use of this IC is quite simple and it is recommended to read the datasheet on the accompanying CD,
for more detailed information.

Firstly to address the PCF8583, the address for this device is ‘1010001X’ the 7th bit is actually
adjustable by setting a +5V or 0V at pin 3 of the IC. On the T89C51 Training Board, the control supply
+5V has been tied to this pin, configuring this bit to be a 1. The X bit as discussed above is for a read
or write and is specified when sending the address information, for a data write this will be ‘10100010’.
After this byte is sent from the microcontroller, the PCF8573 will acknowledge. The address of the
register to be written to or read is then sent. This register address can be the starting point and a series
of data sent to the device.

Normally the control register at location 00 will be the first register to be written to. The control
register is used to set up the device and specify the operation. For the unit to operate as a normal clock,
the function mode at bit 4 and 5, will need to be set to ‘00’, alternatively to set the IC as a event
counter, these bits will be set to ‘10’. The time can then be sent to the device to initialise it. The time is
stored in BCD format, and the initial data will need to be sent in an identical format. There is no need
to start the clock, once the data has been written, the IC will automatically update the count.

For specifying the operation of the alarm, register 08 will need to be set with the appropriate values.
The alarm is enabled or disabled by using the Alarm Enable Bit, which exists in bit 2 of the control
register. Setting this bit to a 1 will enable the alarm. The value the alarm is to trigger at, is then placed
in registers 09h to 0bh.

T89C51 Training Board.doc Page 33/44

T89C51 Training Board Manual

13.6 EEPROM (24LCXX)

The EEPROM is used to store data and it necessary initialisation parameters. A number of different
EEPROM devices can be used for this socket, namely the 24LCXX series from Microchip or the
24CXX series from Atmel, these parts are all available from Futurlec,
In this section we will discuss in detail the Microchip range of devices, for which are datasheet is
included in the accompanying CD. These EEPROM’s can store data for up to 200 years and it is
possible to write and erase to these devices up to 1 Million times. A range of sizes are available from
the 24LC32 up to the 24LC256. These devices have an I2C bus address of ‘1010XXX’. With the last
three values determined by the settings at A2, A1 and A0 on pins 1,2 and 3 of the IC. A +5V control
voltage at these pins will set the address value to a ‘1’. By setting these pins to different values, it is
possible to include up to 8 devices on a single bus. For the T89C51 Training Board, these values have
been preset to ‘100’, thus the complete address for the on-board eeprom is ‘1010100X’, with the last bit
being the read/write bit. To include additional EEPROM on the external I2C bus, it is necessary to set
these bits A2,A1 and A0 to different values than the on-board EEPROM.

To write to the EEPROM, this can be either a single byte write or a page write. The difference being
that the stop bit, is sent at the completion of the transmission. To write to a single byte, the device
address ‘10101000’ is sent, followed by the register address the byte is to be written to. In the case of
the 24LC256, as the memory size is quite large, the register address will consist of 2 bytes, the first
byte being the high address and the next byte being the low address. Following this the data is sent.

To read from the EEPROM, it is necessary to first set the register address to the correct address within
the EEPROM. This is done by first sending the device address followed by the register address for the
data to be read. This is sent as a write instruction, not a read instruction. After sending the address, the
microcontroller generates a start condition and then resends the control byte or device address again,
but this time with the read/write bit set to a read ‘1’. The EEPROM will then place the byte value on
the bus for receiving by the microcontroller. A sequential read for reading a number of bytes is similar
with the exception that the stop bit is generated at the completion of the reading of the data.

T89C51 Training Board.doc Page 34/44

T89C51 Training Board Manual

Fig 18 – EEPROM Socket

T89C51 Training Board.doc Page 35/44

T89C51 Training Board Manual

13.7 I/O Port (PCF8574A)

The PCF8574 is designed to expand the number of I/O points available on the system. If a lot of the
microcontroller I/O pins are being used for ancillary functions, such as communication and as A/D
ports. It is possible to use this device to add another 8 I/O points, which can be read or written to. Up to
8 of these devices can be used on a single I2C bus, enabling a large increase in the number of I/O
points available for a more complex system.

Fig 19 – PCF8574 IC Socket and Connector

The address for the PCF8574 is ‘0100XXX’ or for the PCF8574A this is ‘0111XXX’. The value of
XXX is set by pins A2, A1 and A0 on the PCF device. In the case of the T89C51 Training Board, these
have all been set to 0, thus for a PCF8574A, the address will be ‘0111000’. Each of the I/O points on
the PCF8574 can act as either an input or output. To act as an output, simply write either a 0 or a 1 to
the port pin. This is achieved similarly to the above IC’s. Firstly send the address with a write
indicated, i.e. ‘01110000’. Then write the write the value to be written to the output port. The data is
sent as P7 to P0. The output at the port will not change until the complete byte has been sent and the
PCF8574 acknowledges. Thus the entire port changes state at the same time, on completion of
receiving the entire byte. To read values from the port, simply send the device address with a read
instruction, i.e. ‘01110001’, the PCF8574 will then send the data, following the acknowledge signal.

Interrupts can also be set up on the device, such that an interrupt is generated, if the input changes state.
To use this, the interrupt pin can be connected to the INT pin of the microcontroller, as discussed in the
precious section. Once an interrupt is generated, the microcontroller can then initiate a read of the
device, to obtain the new information.

T89C51 Training Board.doc Page 36/44

T89C51 Training Board Manual

Fig 20 - Writing Data to PCF8574

Fig 21 – Reading Data from PCF8574

T89C51 Training Board.doc Page 37/44

T89C51 Training Board Manual

Chapter 14 – Communication

14.1 Introduction

The T89C51 Training Board is equipped with a number of communication channels to communicate
with high-level devices, such as computers and control systems. These are connected to the
microcontrollers internal UART, which is used to read and send these signals. To set up the UART, a
series of communication registers exist within the microcontroller, these need to be set correctly prior
to using the communication channels. Three options exist for communication with the microcontroller,
these are RS232, RS422 and RS485.

The RS232 port is designed to communicate directly with a computer, by connecting the RS232
connection to the computers serial port. Data can then be sent and received from the board. This is
ideal for setting up a control and monitoring system on the computer, using either Visual Basic, C or
Delphi, to display and record the various values. The high level system can also be used to comtrol the
board, such that a more sophisticated control system is developed using this software and commands
are then sent to the T89C51 board as required.

For the RS422/RS485 ports, these are designed for setting up communication either in a one-to-one
format, between two devices. Or for a multi-board system where a number of boards are connected to
the RS485 bus, and data is placed on this bus, for the entire system to read and monitor.

It is only possible to use one communication option, either the RS232, RS422 or RS485
communication port.

14.2 RS232

Within the T89C51 Training board the necessary RS232 IC’s and support parts are already included,
for RS232 communication with a computer. It is however necessary to set-up the microcontroller, for
the correct baud rate, data bit, parity and other values. This information is available in the T89C51 data
sheet and a thorough understanding of this is recommended prior to using this port. One of the most
common causes of problems with this communication, is using or setting the incorrect communication
speed, resulting in lost data or simply no communication.

Included on the T89C51 Training Board, is the MAX232 level conversion IC. This is used to convert
the RS232 signals to a TTL level signal suitable for the microcontroller. RS232 signals are ± 12, whilst
TTL signals are +5V, connecting the RS232 signals directly to the microcontroller’s UART would
result in damage to the IC.

For two-way communication between the board and a computer, it is necessary to cross the wires. Such
that the TXD or transmission signal from the board is connected to the RXD (receiving) input of the
computer. Similarly the TXD (transmission) signal from the computer is connected to the receiving
input of the microcontroller board. It is also possible to arrange one-way communication by
connecting only the TXD transmission signal to the computer, or alternatively only the TXD signal
from the computer to the board. This is however not recommended, especially in the case of commands
being sent, as it is important these signals are acknowledged, by issuing a confirmation from the
receiving device.

Diagram 9 – RS232 Connector

T89C51 Training Board.doc Page 38/44

T89C51 Training Board Manual

14.3 RS422

In the case of RS422 communication, a 75176 or MAX3088 IC is required to convert these signals to
TTL signals. For 2 way communication, i.e. sending and receiving, 2 IC’s are required, one for sending
and one for receiving, these are installed in the sokcets as shown below,

Fig 22 - 75176 IC sockets and Full/Half Duplex Jumpers, together with RS422/RS485 Jumper

Similarly if only one-way communication is required, only a single IC is required either at the
receiving socket or at the transmission socket, refer to the schematic diagram for this information.

The advantage of RS422, is that it can communicate over much greater distances than RS232, up to
1200metres. Shielded wire however is required for the link between the devices. RS422 is mainly
designed for communication between two devices, whilst RS485, can be used on a bus system with
many devices on the single bus.

It is however possible to connect a series of devices together, however only one unit can be a
transmission unit and the remainder are receiving units. Up to 32 receiving units can be connected in
the case of using the 75176 IC and up to 256 points when using the MAX3088 IC. A standard RS422
connector, consists of 6 pins, 4 of these wires are used for signal wires, i.e. RXA and RXB for
receiving and TXA and TXB for transmission. It is necessary as in RS232 to cross these wires also,
such that the transmission wires of one device are connected to the receiving wires of the other device.

Diagram 10– RS422 Connector

T89C51 Training Board.doc Page 39/44

T89C51 Training Board Manual

14.4 RS485

RS485 communication offers a lot more flexibility than the previous methods, in that signals can be
sent and received on the same bus. Also a number of devices can be connected to the same bus, to form
a network. In the case of the 75176 IC, up to 32 connection points/devices can be connected to a single
bus, whilst for the MAX3088 up to 256 devices can be connected. To implement a network system a
form of addressing needs to be set up to identify each device. Similarly software control needs to
ensure only one device is sending at one time, to avoid signal collisions, and corrupted data.

Only 2 wires are required for sending and receiving data, the direction is controlled by the
microcontroller at port pin PD7. To send data, set PD7 to a 1 and to receive data set PD7 to 0. To
implement RS485, the board needs to be set up as follows,

a) Insert either a 75176 IC or MAX3088 IC in the RS422/RS485 socket.

b) Set the RS422/RS485 jumper to the RS485 side.
c) Set the F/H jumper to the H (Half Duplex) side
d) Short the jumper for the fail safe resistor at position TL
e) Short the jumper for the fail safe resistor at position TH
f) Connect the 2 wire bus to terminal TXB (TX-) and TXA (TX+)

It is now necessary to set up the software, to control this communication. A sample program is included
on the CD, it is worthwhile before implementing a system to study this and other literature to get a
good understanding of controlling and sending messages on such a network.

Fig 23 – RS422/RS485 Connector

T89C51 Training Board.doc Page 40/44

T89C51 Training Board Manual

Diagram 11 – RS485 Connector

T89C51 Training Board.doc Page 41/44

T89C51 Training Board Manual

14.5 Communication Jumpers

RS422/RS485 Jumper: - This is to set the IC Line driver at the position TXD/485 to work either for
RS422 or RS485 communication. Setting the jumper to the TXD position, will enable the IC to work
for RS422 communication and to send/transmit data only. When the jumper is in the 485 position, it
will enable the socket for RS485 communication. This will allow data to be sent and received by this
IC, under the control of the PD7 pin from the microcontroller.

F/H Jumper: - This allows communication in either half or full duplex formats. Full duplex, is when
data is sent and received simultaneously on two separate bus wires as in RS422. Half duplex is when
data is sent and received on the same bus, by alternatively sending and receiving information. This is
the method for RS485 communication and this jumper needs to set accordingly for either RS422 or
RS485 communication.

RL Jumper: - This connects the termination resistor into the RXB (RX-) circuit. This resistor will
stabilise the bus voltages, when signals are sent out and provide a stiff impedance for signal. For short
buses, it is not necessary to include this resistor, however at least one point on the bus a termination
resistor should be included.

RH Jumper: - As above this jumper connects the resistor into the RXA (RX+) circuit.

RZ Jumper: - This connects an impedance between the RX+ and RX- lines. This will also help to
reduce signal reflections for long distance lines and is recommended to jumper this connection in the
case of long distance bus wiring.

TX Jumper: - This connects the termination resistor into the TXB (TX-) circuit. This resistor will
stabilise the bus voltages, when signals are sent out. For short buses, it is not necessary to include this
resistor, however at least one point on the bus a termination resistor should be included.

TH Jumper: - As above this jumper connects the resistor into the TXA (TX+) circuit. It is important to
include this jumper such that this resistance is at least connected at one point on the bus.

TZ Jumper: - This connects an impedance between the TX+ and TX- lines. This will also help to
reduce signal reflections for long distance lines and is recommended to jumper this connection in the
case of long distance bus wiring.

Fig 24 – Communication Jumpers

T89C51 Training Board.doc Page 42/44

T89C51 Training Board Manual

Chapter 15 – Power Supply

15.1 Power Supply Connection

The power supply circuit on the Development Board has been designed for heavy duty, and
will maintain a 5V supply to the circuit under quite high load conditions. A standard plugpack can be
used to supply power to the board, the plugpack pin and shield can be either polarity as a full wave
rectifier is used in the circuit.

The power supply can be connected to either the poarized header or the plugpack connection,
as shown in the photo below. The DC input voltage can be between 9 and 12 V, and should be capable
of supplying at least 500mA.

The red LED will come on to indicate the supply is okay.

Output voltage of 5Vdc is available at several points around the board.

Power LED Plugpack


Polarized Header

Figure 25: Power Supply Connections

T89C51 Training Board.doc Page 43/44

T89C51 Training Board Manual

4 Board Layout

T89C51 Training Board.doc Page 44/44