Development of a RISC Microcontroller



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: mostafagb@

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 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

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

IV. SERIAL PROGRAMMING INSTRUCTION SET of ATmega8 [6]

|Instruction |Instruction Format |Operation |

| |Byte1 |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 |bbbb bbbb |pooo oooo |Read Flash memory at word address a:b. Lower 8-bit is read |

| | |(addrs H) |(addrs L) |(data out) |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 |Load max 64 bytes (32 words) of program codes into temporary |

| | | | |(data in) |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 unprogrammed |

|Read Fuse High Bits |0101 1000 |0000 1000 |0000 0000 |oooo oooo |Upper Eight Fuse Bits are read. LH indicates unprogrammed |

|Write 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 RMCKIT

Assume 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 $020

STKINIT: ldi r16, 0x5F ; stack initialize

out spl, r16

ldi r16, 0x04

out sph, r16

PRBINIT: ldi r16, 0xFF ;

out DDRB, r16 ; PORTB are output

BUSY: sbi PORTB, PBo

rcall DELAY

cbi PORTB, PBo

rcall DELAY

rcall DELAY

rjmp BUSY

DELAY: ldi r17, 5

cagain: ldi r18, 250

magain: ldi r19, 250

fagain: dec r19

brne fagain

dec r18

brne magain

dec r17

brne cagain

ret

.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 Interface

The 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 RS232(USB 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] ; AVR Studio 4, ATmega8 Assembler

[2] software/midepack02516.exe for 8051

Assembler

[3] forMocroTalk-8051 Trainer.

[4] for Universal ROM Programmer

[5] for USB ( RS232 Converter Cable

[6] doc2486.pdf for ATmega8 data sheet.

[7] Mostafa, Golam : 8086/Microprocessor/Interfacing and System Design ; Publisher: Publication Department, Karighar R&D Center:

-----------------------

[pic]

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download