+ All Categories
Home > Documents > Development of a RISC Microcontroller · Web view( Modification of the GUI interface\ace to include...

Development of a RISC Microcontroller · Web view( Modification of the GUI interface\ace to include...

Date post: 28-Apr-2018
Category:
Upload: phamnguyet
View: 222 times
Download: 0 times
Share this document with a friend
6
Development of a RISC Microcontroller Learning Kit using ATmega8 Architecture Golam Mostafa Department of Electrical and Electronic Engineering, Ahsanullah University of Science and Technology 141-142 Love Road, Tejgaon Industrial Area, Dhaka-1208, Dhaka -1208, Bangladesh Email: [email protected] Abstract: The Atmel’s ATmega8 microcontroller apart from functioning as a general-purpose MCU chip, supports built-in multi-channel High Frequency High Resolution Pulse Width Modulator, Variable Square Wave Generator, Analog-to-Digital Converter, Capture Unit for external event, Fuse Bits and Boot Loader. The students, teachers, scientists, engineers and amateurs who wish to understand the functioning of these fascinating features through experiments and examples need a ‘low cost, handy and friendly’ Learning Kit. This paper has presented the works summary of the design and implementation of a user-friendly risc microcontroller Learning Kit using ATmega8 architecture. We will refer to this kit by the name RMCKIT, which stands for RISC Microcontroller Learning Kit. Keywords – RISC Microcontroller, MicroTalk- 8051, Monitor Program, Virtual COM Port, ATmega8 AVR. I. INTRODUCTION A functioning RMCKIT requires the realization of the following hardware and software objects: Hardware of Fig. 1, Fig. 3 and Fig. 4. Graphical User Interface (GUI) Interface of Fig. 5 to interact with the IBMPC for programming the ATmega8 chip via the logic board of Fig. 1. The Firmware-A (FWA) of Fig. 6 for the Master MCU (U2) of Fig. 3 to interact with the GUI interface during programming phase of the ATmega8. The development of the above objects requires the services of the following 3 rd party resources: IBMPC with WINXP operating system. Visual Basic 6 Programming Tool to develop the GUI Interface of Fig. 5. AVR Studio 4 [1] to develop the application/test programs for the ATmega8 chip. MIDE-51 [2] to develop/test binary codes for FWA – the Control Program for the Master MCU (U2) of Fig. 4. MicroTalk-8051 [3] of Fig.2 to develop/test the Hardware of Fig. 1 and the GUI Interface of Fig. 5. TOP2005 Universal ROM Programmer [4] for fusing the FWA inside the code memory of U2 of the RMCKIT. USB RS232 Conversion cable [5] to operate the RMCKIT using the USB port of the IBMPC. II. HARDWARE COMPONENTS of the RMCKIT
Transcript

Development of a RISC MicrocontrollerLearning Kit using ATmega8 Architecture

Golam MostafaDepartment of Electrical and Electronic Engineering, Ahsanullah University of Science and Technology

141-142 Love Road, Tejgaon Industrial Area, Dhaka-1208, Dhaka -1208, BangladeshEmail: [email protected]

Abstract: The Atmel’s ATmega8 microcontroller apart from functioning as a general-purpose MCU chip, supports built-in multi-channel High Frequency High Resolution Pulse Width Modulator, Variable Square Wave Generator, Analog-to-Digital Converter, Capture Unit for external event, Fuse Bits and Boot Loader. The students, teachers, scientists, engineers and amateurs who wish to understand the functioning of these fascinating features through experiments and examples need a ‘low cost, handy and friendly’ Learning Kit. This paper has presented the works summary of the design and implementation of a user-friendly risc microcontroller Learning Kit using ATmega8 architecture. We will refer to this kit by the name RMCKIT, which stands for RISC Microcontroller Learning Kit.

Keywords – RISC Microcontroller, MicroTalk-8051, Monitor Program, Virtual COM Port, ATmega8 AVR.

I. INTRODUCTIONA functioning RMCKIT requires the realization of the

following hardware and software objects: Hardware of Fig. 1, Fig. 3 and Fig. 4. Graphical User Interface (GUI) Interface of Fig. 5 to

interact with the IBMPC for programming the ATmega8 chip via the logic board of Fig. 1.

The Firmware-A (FWA) of Fig. 6 for the Master MCU (U2) of Fig. 3 to interact with the GUI interface during programming phase of the ATmega8.

The development of the above objects requires the services of the following 3rd party resources: IBMPC with WINXP operating system. Visual Basic 6 Programming Tool to develop the GUI

Interface of Fig. 5. AVR Studio 4 [1] to develop the application/test programs

for the ATmega8 chip. MIDE-51 [2] to develop/test binary codes for FWA – the

Control Program for the Master MCU (U2) of Fig. 4. MicroTalk-8051 [3] of Fig.2 to develop/test the Hardware

of Fig. 1 and the GUI Interface of Fig. 5. TOP2005 Universal ROM Programmer [4] for fusing the

FWA inside the code memory of U2 of the RMCKIT. USB RS232 Conversion cable [5] to operate the

RMCKIT using the USB port of the IBMPC.

II. HARDWARE COMPONENTS of the RMCKIT

Fig. 1 Pictorial View of the RMCKIT Fig. 2 Development Setup using MicroTalk-8051

Fig. 3 Hardware Block Diagram for the RMCKIT Fig. 4 Components Layout for the RMCKIT of Fig. 1

USB ß ---- > RS232Converter

P1 U1: MAX232

RxRSTxRS

COMCOM

RxRSTxRS

COM

TxTTLRxTTL

COM

TxTTLRxTTL

U2: 89S52

RST

+5V

SW1

RST/(P14)

+5V

R4 1k5

Q2C828

Q3C828

R54k7

R61k5

C9100uF0V

RST/

U3: ATmega8

SCK (PB5)MISO (PB4)MOSI (PB3)

SCK(P17)MISO (P16)MOSI(P15)

XT2XT2

Y2

PB0

LEDR2

1k5

Rx

1503

P10

LEDR1

IBMPC

22

1MHz

III. SOFRWARE COMPONENTS of the RMCKIT

Fig. 2 Graphical User Interface for the RMCKIT

Fig. 5 Graphical User Interface for the RMCKIT of Fig. 1

Fig. 6 Flow Chart describing the Control Logic of Firmware-A

L1:

Initialization:Counterflags

Start

L2:

Initialization:Serial Port

L3:

IsData Readyin Tx Buffer

?

N

YL4:

Read from Rx & save at ASC

display at DP0DP1

f0=1?

Y L9:

YL5:

ASC=05?

N

Y Enquiry CodeReceivedL7:

Proceed toReceive Codesof caption (a) of Intel-Hex

1 --> f0

L8:

ACK (06H) --> PC

L8a

f1=1?

L10:

Proceed toReceive Codesof caption (b) ofIntel-Hex Format

Y L13 :

N

ASC = : ?

N

1 --> f1

L12a:

f2 = 1?

Y L16:

N

Proceed toReceive Codesof caption (b) - (f)of Intel-Hex Format

Save Data at ASCII table

Receive of(b) done

?

N

YL15a:

1 --> f202 --> Counter R2

ASCII ---> Hexasve at Hex Table @R0

(b) = 00?

save (b) [InfoBytes] ---> INBYTE

L15c:

save frame lengtn---> TBYTE

LX:

N

Y

TxEND(04H) -->PC

f3=1?

Y LY :

Save Data at ASCII table @R1

frame receivedone

?

Y L20:

Convertall ASCII --> HEX

L20z:

Compute CHSUMfrom Rcvd Hex

CHKSUMagrees

?

L22:

CHKSUMERR(18H)----> PC

L23:

JMP 0000H

N

Y L24:

Write Hex--> Flash / EEPROM

Get Ready toReceive

Next Frame1 --> f0

L25:

L8 : 737ab : GM: 23/10/2005

R1

ASCII TableHex Table

R0

N

No more Frame to Receive

ExitJMP 0000 Exit

JMP 0000

C100H Intel-Hex Frame : 02 0000 00 1FC0 1F ß -à ß -à ß ----à ß -à ß ----à ß ---à (a) (b) (C ) (d) (e) (f)

IV. SERIAL PROGRAMMING INSTRUCTION SET of ATmega8 [6]

Instruction Instruction Format OperationByte1 Byte2 Byte3 Byte4

Programming Enable 1010 1100 0101 0011 0000 0000 0000 0000 Serial Programming is enabled with RST/-pin at LL. Byte2 (53h) is echoed while writing Byte3 of Instruction Format.

Chip Erase 1010 1100 1000 0000 0000 0000 0000 0000 Contents of Flash and EEPROM are erased and set to FFs.Read Program memory 0010 H000 0000 aaaa

(addrs H)bbbb bbbb(addrs L)

pooo oooo(data out)

Read Flash memory at word address a:b. Lower 8-bit is read first with H-bit at LL and then Higher 8-bit with H = LH.

Load Program Memory Page 0100 H000 0000 0000 000b bbbb iiii iiii(data in)

Load max 64 bytes (32 words) of program codes into temporary buffer of ATmega8 before actually writing them.

Write Program Memory Page 0100 1100 0000 aaaa bbb0 0000 0000 0000 All the loaded program codes are written into Flash memory starting at location a:b.

Read EEPROM Memory 1010 0000 0000 000a bbbb bbbb oooo oooo 8-bit content of EEPROM location at address a:b is read. Write EEPROM Memory 1100 0000 0000 000a bbbb bbbb iiii iiii 8-bit data is written into EEPROM at location a:b.Read Lock Bits 0101 1000 0000 0000 0000 0000 xxoo oooo Lock buts are read. LH indicates unprogrammed.Write Lock Bits 1010 1100 1110 0000 0000 0000 11ii iiii Lock bits are programmed as per values of i.Read Fuse Low Bits 0101 0000 0000 0000 0000 0000 oooo oooo Lower Eight Fuse Bits are read. LH indicates unprogrammedRead Fuse High Bits 0101 1000 0000 1000 0000 0000 oooo oooo Upper Eight Fuse Bits are read. LH indicates unprogrammedWrite Fuse Low Bits 1010 1100 1010 0000 0000 0000 iiii iiii Lower Eight Fuse Bits are programmed as per values of i.Write Fuse High Bits 1010 1100 1100 0000 0000 1000 iiii iiii Higher Eight Fuse Buts are programmed as per values of i.

V. FUNCTIONAL DESCRIPTION of the HARDWARE and SOFTWARE COMPONENTS of the RMCKIT

A. Introduction The RMCKIT is a complete system to realize and therefore its design and development approach must follow ‘Small Start Strategy (SSS)’. The SSS approach takes a ‘Simple and Elementary (Basic)’ idea and tests its functionality. The idea could be a ‘small electronic circuit’ or ‘a single line of program code’. Once the 1st idea is established, the 2nd idea (adding more electronic circuits or/and adding more program codes) is joined with the 1st idea and now the two ideas are tested as a 'single idea’. This way, the next and the next ideas are added and eventually the final object (the system) is achieved. The SSS method needs a functioning setup onto which the ideas could be tested, modified and retested. In the case of RMCKIT, we will be required to test a large number of hardware (Fig. 4) and software (Fig. 5, 6) components for which the MicroTalk-8051 based setup of Fig. 2 would be a good choice.

The MicroTalk-8051 (Fig. 2) is an 89S52 microcontroller based trainer with breadboard, RAM and RS232 serial communication link. The ATmega8 and its associated reset circuitry are placed on the breadboard, its ISP (In System Programming)-pins [6] are connected with suitable IO ports (Fig. 7) of the MicroTalk-8051 trainer.

The experimental codes of FWA of Fig. 6 are downloaded from IBMPC into the RAM area of the MicroTalk-8051 and are then executed. The experimental codes of the GUI Interface of Fig. 5 are launched and tested through interaction with the FWA codes already downloaded.

B. Working Principle of RMCKITAssume that we have designed, developed and tested all

the hardware and software components that are required for the functioning of a stand alone RMCKIT. We wish to use this system to transfer the binary codes of the program test.asm into the buffer area of U2 (Fig. 3). The U2 will fuse these codes inside the code memory of ATmega8 (U3 of Fig. 3) under the supervision of the FWA, which strictly follows the ATmega8’s Serial Programming Instruction Set of Section-IV.

The program test.asm tells the ATmega8 to blink the LEDR2 (Fig. 3, 4) continuously. Let us list the sequences/events that take place during this data transfer/write session. The list will help us understanding the roles played by GUI and FWA. The contents of the program : test.asm. These source codes

are written using AVR Studio 4. .include "m8def.inc".cseg.org $000

RESET:rjmp STKINIT

.org $020STKINIT: ldi r16, 0x5F ; stack initialize

out spl, r16ldi r16, 0x04out sph, r16

PRBINIT: ldi r16, 0xFF ;out DDRB, r16 ; PORTB are output

BUSY: sbi PORTB, PBorcall DELAY

cbi PORTB, PBorcall DELAY

rcall DELAYrjmp BUSY

DELAY:ldi r17, 5cagain: ldi r18, 250magain: ldi r19, 250fagain:dec r19

brne fagaindec r18brne magaindec r17brne cagainret

.exit

The following are the Intel-Hex format [7] for the binary codes of the test.asm program. AVR Studio 4 has created the Intel-Hex formatted file.

:020000020000FC:020000001FC01F:100040000FE50DBF04E00EBF0FEF07BBC09A03D052:10005000C09801D0FBCF15E02AEF3AEF3A95F1F7BF:0A0060002A95D9F71A95C1F7089503:00000001FF

The GUI Interface of Fig. 5 performs the following tasks:* GUI sends ‘Roll Call Inquiry’ command to the

RMCKIT to check that the RMCKIT is ready for communication.

* FWA (Fig. 6) makes an acknowledgement (ACK) to the GUI by sending code 06H.

* User selects ATmega8CM (Code Memory Programming) and as a result the various Command Buttons if the GUI become active.

* GUI sends ‘Erase Command’ to the RMCKIT. The FWA executes erase instruction as per Section-IV and the memory space of ATmeg8 gets erased.

* GUI sends ‘Write Command’ to the RMCKIT. The FWA configures the data structure for carrying out subsequent write operations on the code memory of ATmega8 as per instruction set of Section-IV.

* GUI opens the file test.hex send it to the RMCKIT one frame at a time.

* FWA receives a frame, strips out the control information from the frame and then writes the binary codes into the code memory locations as specified in the frame.

* The process keeps going until the GUI finishes transmitting all the frames of the test.hex file and the FWA has finished writing them onto the code memory of the ATmega8.

* The data communication between the GUI and the FWA undergoes under strict two-way handshaking for both byte and frame transmission and reception.

C. Graphical User InterfaceThe GUI interface of Fig. 5 is developed using Visual

Basic 6 programming tool. The interface is originally designed to communicate with physical COM1-port of IBMPC under the supervision of the MSComm1 control. However, the interface can communicate with ‘Virtual COM5 Port (VCOM5)’ (Fig. 9), which in turn can communicate with USB controller. The ‘Properties List of MSComm1control is given below in Fig. 8.

Fig. 8 MSComm1 Control Properties

Fig. 9 Virtual Serial COM Port Architecture

The present day IBMPCs are not equipped with physical COM port connectors any more. They come with USB ports As a result, should the previous PCs, which have been monitoring and controlling the industrial machineries using COM ports get broken beyond repair then these PCs have to be replaced by the PCs with USB ports. This incompatibility has been solved with the introduction of Virtual COM Port. The original physical COM port dependent application program is now happy to communicate with the virtual COM port. The VCOM port is a software-simulated port, which contains codes to accomplish RS232 USB conversions. The program that creates the VCOM port is supplied along with the RS232USB conversion cable.

V. CONCLUSIONS

All the components of the RMCKIT have been successfully developed, tested and joined together to make a working and useable learning kit of Fig. 1. The RMCKIT will hopefully allow a user to learn all technical aspects of the ATmega8 through experiments. The author believes that the interested group may come forward to develop the following gadgets, which will certainly enhance the operation of the RMCKIT. Developing the GUI Interface using Java or similar high-

level platform. Developing USB protocol to avoid the use of the costly

RS232 USB conversion cable. Modification of the GUI interface\ace to include the

ATmega16 and ATmega32 chips.

b

REFERENCES

[1] http://www.atmel.com ; AVR Studio 4, ATmega8 Assembler[2] www.opcube.com/software/midepack02516.exe for 8051 Assembler

Tx, RXRS232

59

VirtualSerial

COM Port 5(VCOM5)

VB6 BasedGraphical

User Interface

HarddiskTest.hex

AsynchronousSerial

CommunicationController

USBInterface

Controller

CO

M1

Por

tU

SB

Po

rt TX, RXUSB

[3] www.krdcbd.com forMocroTalk-8051 Trainer. [4] www.ty51.com for Universal ROM Programmer[5] www.CDW.com for USB RS232 Converter Cable[6] www.atmel.com/doc2486.pdf for ATmega8 data

sheet.[7] Mostafa, Golam : 8086/Microprocessor/Interfacing

and System Design ; Publisher: Publication Department, Karighar R&D Center: www.krdcbd.com


Recommended