Chapter 7 : Development systems
7.1 At the end - from the beginning...
As always, beginning is the most difficult. You have bought microcontroller, you have learned everything about its systems and registers, you have great idea how to apply all that in practice. The only thing left over to you is to start...
How to start working?Microcontroller is a good-natured “giant from the bottle” and there is no need for extra knowledge in order to use it.
In order to create your first device under microcontroller’s control, you need: the simplest PC, program for compiling into machine code and simple device for “transferring” that code from PC to chip itself.
The process itself is quite logical but dilemmas are anyway common, not because it is complicated but for the fact that there are numerous variations. Let’s start...
Writing program in assemblerIn order to write a program for the microcontroller, a specialized program in Windows environment may be used. It may, but it does not have to... On using such a software, there are numerous tools which facilitate operating (first of all simulator tool). This is a distinct advantage, but there are other ways too. Basically, text is the only important thing. Because of that any program for text processing can be used for writing program. The point is to write all instructions in order they should be executed by the microcontroller. The rules of assembly language are observed and instructions are written as they are defined. Program idea is followed. That’s all!
;RESET VECTOR
CSEG AT 0
JMP XRESET ; Reset vector
CSEG
ORG 100H
XRESET: ORL WMCON,#PERIOD ; Defining of Watch-dog period
ORL WMCON,#WDTEN ; Watch-dog timer is enabled
If a document is written for being used further by programmer then it has to have an extension, .asm in its name, for example: Program asm.
If a program is written using a specialized program (mplab), this extension will be automatically added. If any other program for text processing (Notepad) is used then the document should be saved and additionally renamed. For example: Program.txt -> Program.asm. This procedure is not necessary. The document may be saved in original format while Its text may be copied to programmer for further use.
As seen, text of the program is the only thing that matters.
Compiling into machine codeMicrocontroller “does not undrestand” assembly language. That is why this program should be compiled. If a specialized program is used- nothing simpler - a machine code compiler is a part of the software! Problem is solved by a click on the appropriate icon. The result is a new document which has extension .hex in its name. That is the same program you have already written, but compiled into machine language which microcontroller perfectly understands. The common name of this document is “hex code” and represents apparently meaningless series of numbers in hexadecimal numerical system.
:03000000020100FA1001000075813F 7590FFB29012010D80F97A1479D40 90110003278589EAF3698E8EB25B A585FEA2569AD96E6D8FED9FAD AF6DD00000001FF255AFED589EA F3698E8EB25BA585FEA2569AD96 DAC59700D00000278E6D8FED9FA DAF6DD00000001FF255AFED8FED 9FADAF6DD000F7590FFB29013278 E6D8FED9FADAF6DD00000001FF2 55AFED589EAF3698E8EB25BA585 FEA2569AD96DAC59D9FADAF6D D00000001FF255AFED8FED9FADA F6DD000F7590FFB29013278E6D82 78E6D8FED9FA589EAF3698E8EB2 5BA585FEA2569AD96DAF6DD000 00001FF2DAF6DD00000001FF255A ADAF6DD00000001FF255AFED8FE D9FA
In case some other software for writing program in assembler is used, a software especially installed for compiling into machine code must be used. This compiler is activated, document with extension .asm is open and the appropriate command is executed. The result is the same- a new document with extension .hex. The only problem is that it is stored in your PC.
Copy program to a microcontrollerAcable for serial communication and a special device called programmer are necessary to transfer “hex code” to the microcontroller. There are also several options on how to do it.
A great deal of programs and electronic circuits having this purpose can be found on Internet. Do as follows: open hex code document, adjust a few parameters and click on the icon for compiling. After a while, a series of zeros and units will be programmed into the microcontroller through the serial connection cable. The only thing left over is to transfer programmed chip to the final device. In case it is necessary to change something in the program, the previous procedure may be repeated.
How it operates?
Working with program developed by Mikroelektronika will be in short described here. Everything is very simple...
Start the program Mikroelektronika Asm51 Console. A window appears...
...Open a new document: File -> New. Introductory header appears. Write your program or copy text...
... Save and name your document : File -> Save As... (Document name is limited to 8 characters!)
Finally, to compile program into HEX code select: Project -> Build or click on the icon “play”.
If everything works properly, the computer will reward you with a minireport!
Program is written and successfully compiled into machine code. It is only left over to load it to the microcontroller. For this purpose it is necessary to have programator and software which interfere between PC and programator hardware.
Start the program 8051 Flash_setup.exe...
Program installation is performed as usual - It is necessary to select following commands for several times: Next, Accept, Next...
...and finally - Finish!
Program has been installed and ready for use. Settings are simple and there is no need to explain them more (type of the microcontroller in use, frequency and type of clock oscillator and similar).
- Connect PC and programmer via USB cable.
- Load HEX code by command: File -> Load HEX.
- Click on the “Write” pushbutton and wait...
That’s all! Program is loaded into the microcontroler and everything is ready for operating. If you are not satisfied, make some changes in your program and repeat the procedure. Until when? Until you feel satisfied...
What are the development systems?
A device which in testing program phase for the microcontroller can simulate any device is called- development system. Beside programmer, power supply unit and microcontroller’s socket, development system also contains elements to activate input pins and monitor state on the output pins. In the simplest version, each pin is connected to one pushbutton and one LED. Higher quality versions have LED displays, LCD displays, temperature sensors and all other elements which the final device can be supplied with. These peripherals could be connected to MCU via miniature jumpers. In that way, a program may be checked in practice during its writing because the microcontroller cannot “know” whether its input is activated by a pushbutton or by a sensor built in a real machine.
7.2 Easy8051A Development system
This is one of high-quality development systems used for programming 8051 compatible microcontrollers manufactured by Atmel. Beside chip programming, this system enables direct testing all parts of a program because it contains the most components which are normally built in the real devices.
Easy8051A Development system consists of:
- Sockets for placing microcontrollers (14, 16, 20 and 40- pin packages)
- Connector for external power supply (DC 12V)
- USB programmator
- Power Supply Selector (external or via USB cable)
- Quartz Crystal Oscillator 8 Mhz
- 32 LEDs for output pins’ state indication
- 32 pushbuttons for activating input pins
- Four 7-segment LED displays in multiplex mode
- Graphic LCD display
- Alphanumeric LCD display (4- or 8- bit mode)
- Connector and driver for serial communication RS232
- Digital thermometer DS1820
- 12- bit A/D converter (MCP3204)
- 12- bit D/A converter (MCP4921)
- Reference voltage source 4.096V (MCP1541)
- Multiple-pin connectors for direct access to I/O ports
Several following pages describe in short some circuits within this development system- it is more illustration of its possibilities than complete instructions. Besides, familiarizing with details of this device testifies that microcontrollers and tools for handling them are neither privilege nor secret of the few.
Sockets
All microcontrollers manufactured by Atmel appear in a few standard DIP packages. In order to enable their programming using one device, corresponding pins on sockets are connected in parallel (pins having the same name). In accordance to that, by being placed in the appropriate socket, each microcontroller will be automatically properly connected! Figure on left shows in detail microcontroller in 40-pin package and connection of one of its I/O pins (P1.5) as well. As seen, the pin can be connected to some external device (connector PORT1), LED (microswitch SW2), pushbutton or resistor through connectors. In the last two cases, polarity of voltage is selected using on board jumpers.
Programmer
The purpose of the programmer is to transfer HEX code from PC to the appropriate pins and provide regular voltage levels during chip programming as well. In this case it belongs to development system and should be connected to PC via USB cable. Once programming is completed, pins used during that proces are automatically available for other application.
Development system power supply
There is a connector for external power supply source (AC/DC, 8-16V) on the development board. Besides, voltage necessary for device operating can be also obtained from PC via USB cable. Jumper J5 is used for power supply selecting.
8MHz Oscillator
EASY8051A Development system has got built in oscillator used as a clock signal generator. Frequency of this oscillator is stabilized by quartz crystal. Besides, during chip programming, internal RC oscillator can be selected instead.
LEDs for output pins’ state indication
All I/O ports pins are connected to one LE diode each, which enables visual indication of their logic state. In case that presence of direct polarized LEDs and serial resistors is not acceptable in very application, DIP switch SW2 enables them to be disconnected from the port.
Pushbuttons for activating input pins
Similar to LEDs, each I/O port pin is connected to one pushbutton on the development board. It enables simple activation of input pins. Jumper J6 is used for selecting voltage polarity (+ or -). Press on the appropriate pushbuttons brings selected voltage to the pins.
7-segment LED displays
For being often applied in industry, four high-performance LED displays set up in multiplex mode belong to the development board. Displays’ segments are connected to the port P0 through resistors. Transistor drivers for activation of individual digits are connected to the first four port P1 pins. It enables testing programs which use 7-segment displays with minimal use of I/O ports. Similar to LEDs, DIP switch SW2 disconnects transistor drivers from microcontroller’s pins.
LCD displays
EASY8051A Development system enables connecting to eather graphic or alphanumeric LCD display. Both types are connected by simple being placed into appropriate connector and by switching position of the jumper J8. If displays are not in use, all pins used for their operation are available for other purpose. Beside display connector, there is also potentiometer for contrast regulation on the board.
Serial communication via RS232
In order to enable testing programs which use serial communication, development system has built in standard 9-pin SUB-D connector. The circuit MAX232 is used as a driver for voltage adjustment.
As it is case with other embedded systems, electronics which suppports serial communication can be enabled or disabled by using jumpers J9 and J10.
DS1820 Digital thermometer
Temperature measurement is one of the most common tasks of devices which operate in industry. For that reason, there is a circuit DS1820 on the EASY8051A development system board which measure temperature in the range of -55 to +125oC with accuracy greater than 0.50. Results of measuring are transferred via serial communication to the pins P3.3 or P2.7. Jumper J7 is used for selecting pins for receiving data. In case that no one jumper is installed, port pins are available for other application.
Built in 12-bit AD Converter MCP3204 has four input channels connected to on-board connectors. Data are interchanged with the microcontroller via SPI serial communication using pins P1.5, P1.6, P1.7 and P3.5. If A/D converter is not in use, these pins can be used for other purpose (DIP switch SW1). In order to check operating, there is a potentiometer on the development board used as a variable voltage source. It can be brought to the converter’s input pins using one of four jumpers J12. As a particular convenience, a reference voltage source MCP1541 (4,096V) is built in. Jumper J11 is used to select whether converter will use this voltage or 5V voltage.
12-bit D/A converter MCP4921
Digital to analog conversion (D/A) is another operation often performed by the microcontroller in practice. For that purpose, there is a special on-board chip which interchanges information with the microcontroller via SPI communication. It can also generate analog voltage in 12-bit resolution on its output pin. In case it is not in use, all microcontroller’s pins are available for other purpose using DIP switch SW1. As it is case with A/D converter, jumper J11 is used for selecting reference voltage.
Connectors for direct access to I/O ports
In order to enable direct connection between microcontrollers’ports and additional components, each of them is connected to one on-board connector. Besides, two by two pins on connectors are connected to power supply voltage while each pin can be connected to + or - polarity of voltage via resistors (pull up or pull down resistors). Presence and connecting of these resistors are defined by jumpers. Jumper J3 which controls port P3 is shown on the figure.
