Sei sulla pagina 1di 33

ET-BASE AVR ATmega64/128 User’s Manual

ET-BASE AVR ATmega64/128


ET-BASE AVR ATmega64/128 which is a Board
Microcontroller AVR family from ATMEL uses MCU
No.ATmega64 and ATmega128 64PIN. Board ET-BASE AVR
ATmega64/128 uses MCU’s resources on board mainly and
arranges Pin I/O as Port PA, PB, PC, PD, PE, and PF,
Port ET-CLCD, and including Port for downloading
Program, it makes us more convenient to apply for
various project works. Moreover, there’s addition
circuit Driver RS-232, so we can use RS-232 Serial Port
Communication easily and conveniently.

Specifications
• Use MCU AVR family No.ATmega64, ATmega128 from
ATMEL 8BIT to be permanent MCU on board, and
XTAL 16 MHz. Moreover, this MCU has other
interesting specifications as following;
- Flash Memory 64 K Bytes for ATmega64 and 128
K Bytes for ATmega128, and RAM 4 K Bytes
- EEPROM 2K Bytes for ATmega64 and 4 K Bytes
for ATmega128, in this case, we can erase
and re-write data more than 100,000 times.
- Maximum 53 I/O Pins
- Circuit SPI Communication 1 Channel, I2C 1
Channel, Programmable Serial USARTs 2
Channel
- ADC 10-Bit 8 channel
- Timers/Counter 8-Bit 2 Channel,
Timers/Counter 16-Bit 2 Channel, 8-Bit PWM 2
Channel, Watchdog Timer, Real Time Counter
• 6 I/O Port 10PIN; PA,PB,PC,PD,PE, and PF
• Port ISP LOAD for program MCU (must use with ET-
AVR ISP or ISP Programmer that has the same type
of Pin arrangement).
• Line Driver for RS232 Serial Port Communication
2 Channel; one Port for interfacing with Signal
PE0(RXD0) and PE1(TXD0) and other one Port for
interfacing with Signal PD2(RXD1) and PD3(TXD1),
in this case, we can test connection of circuit
RS232 Serial Port Communication easier.
• Circuit for connecting with Character LCD
Display Monitor (ET-CLCD) and VR for contrasting
brightness of LCD, in this case, it is

ETT CO.,LTD -1- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual
interfaced circuit with LCD as 4 Bit Interface
type.
• Circuit Regulate +5V/1A for supplying power into
circuit of LCD Display Monitor and I/O
components for using with Power Supply that is
not much than +5V and red LED.
• PCB Size 8 x 6 cm.

Structure of Board

• No.1 is MCU No.ATmega64 or ATmega128 AVR family


from ATMEL.
• No.2 is Switch RESRT to reset operation of MCU.
• No.3 is Crystal 16 MHz.
• No.4 is Resistor to contrast brightness of LCD.
• No.5 is PORTC 8 Bit; PC0-PC7.
• No.6 is Port ISP LOAD to download Hex File into
MCU.
• No.7 is Port ET-CLCD to connect with Character
LCD as 4 Bit type.

ETT CO.,LTD -2- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

• No.8 is PORTD 8 Bit; PD0-PD7.


• No.9 is PORTB 8 Bit; PB0-PB7.
• No.10 is PORTE 8 Bit; PE0-PE7.
• No.11 is PORTF 8 Bit; PF0-PF7.
• No.12 is PORTA 8 Bit; PA0-PA7.
• No.13 and 14 are Connector RS232 for general
usage.
• No.15 is LED Power to display status of Power
Supply +5VDC.
• No.16 is Connector Power Supply.

Connectors

For Connector Port I/O from MCU, it is designed


and is provided through 6 Connectors IDC-Header 10PIN
(2X5); PA, PB, PC, PD, PE, and PF respectively. Each
Connector consists of Signal I/O that is connected
directly from Pin MCU. The external connecting point of
board is shown as following;
• Connector Power Supply of Board
• Connector PORTA 8 Bit; PA0-PA7
• Connector PORTB 8 Bit; PB0-PB7
• Connector PORTC 8 Bit; PC0-PC7
• Connector PORTD 8 Bit; PD0-PD7
• Connector PORTE 8 Bit; PE0-PE7
• Connector PORTF 8 Bit; PF0-PF7
• Connector ET-CLCD for interfacing with LCD
Character type
• Connector RS232 2 Channel; one channel for
interfacing with Signal PE0(RXD0) and PE1(TXD0)
and other one channel for interfacing with Signal
PD2(RXD1)and PD3(TXD1), in this case, we can test
connection of circuit RS232 Serial Port
Communication easily.
• Connector ISP LOAD for downloading HEX File into
MCU

ETT CO.,LTD -3- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

Port PA 8 Bit

Port PB 8 Bit

Port PC 8 Bit

ETT CO.,LTD -4- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

Port PD 8 Bit

Port PE 8 Bit

Port PF 8 Bit

ETT CO.,LTD -5- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

Port ISP LOAD

Picture displays circuit for connecting with ISP LOAD.

Port ET-CLCD: It is used with Character Type LCD for


connecting as 4 Bit type. It uses signal from Port PG
and PD (PD7) to connect with LCD. In this case, we must
use the signal name to be reference and must interface
all 14 cables corresponding with the truly name on the
Connector.

ETT CO.,LTD -6- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

1 2 3 4 5 6 7 8 9 10 11 12 13 14
GND +VCC VO RS RW EN D0 D1 D2 D3 D4 D5 D6 D7

Picture displays Pin Arrangement of Character LCD


Standard.

Port RS232 2 Channel: It is used 1 Channel to connect


with Signal PE0(RXD0) and PE1(TXD0) and other one
Channel for interfacing with Signal PD2(RXD1) and
PD3(TXD1).

ETT CO.,LTD -7- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

Picture displays circuit for connecting with RS232.

To Download Hex file into MCU

It is necessary to use ET-AVR ISP or other types


of ISP Programmer such as AVRISP from ATMEL to download
Hex File into MCU AVR family from ATMEL, especially
procedure of Serial Programming Type.
If we use ET-AVR ISP, we must download Hex File
through Parallel Port of computer and must use it with
ET-CAP10P from ETT and Software PonyProg2000 program
that can use with ETT Board well. User can learn
general usage from menu HELP by self, in this case, we
will only mention procedure to setup program
PonyProg2000 for using with all versions Board AVR
family from ETT.

ETT CO.,LTD -8- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

Structure of Board ET-AVR ISP

• No.1 is Port for connecting with ET-CAP10P from


ETT to program Hex File into MCU.
• No.2 is LED PGM (GREEN) to display status of
programming or to download Hex File into MCU.
• No.3 is LED PWR (RED) to display status of
supplying power on board.
• No.4 is Port for connecting with Board Target that
can program Hex File into Board ET-AVR STAMP
ATmega64 by inserting Board ET-AVR ISP at the
position of Port ET-PSPI. Pin arrangement is shown
as in the picture below;

Pin Position Signal’s Name


1 MOSI
2 VCC
3 Disable
4,6,8,10 GND
5 RESET
7 SCK
9 MISO

ETT CO.,LTD -9- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

To Connect Component for Programming Hex File

We must use ET-CAB10PIN and Program PonyProg2000


to program Code (Hex File) into AVR MCU. We must
interface ET-CAB10PIN with Port Printer and then set
Jumper for using Program PonyProg2000. Next, interface
cable Download at the Connector ET-PSPI Download of
Board, then supply power into board. We should take off
all external components that interface with Port PB
before programming code Hex File. The feature of
connection is shown as in the picture below.

(LEFT) ET-CAP10P V2.0 (RIGHT) ET-CAP10P V1.0

Picture displays Set Jumper and interface cable


Download of ET-CAP10P for using with AVR.

ETT CO.,LTD -10- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

Picture displays the connection ET-AVR ISP with ET-BASE


AVR ATmega64/128, in this case, Pin position of one
board must be corresponding with other one board.

To program Board ET-BASE AVR ATmega64/128 by


using Program PonyProg2000

Program Ponyprog2000 is a program for downloading


data Hex File into CPU AVR family through Serial
Programming Type. This method can be used with all
versions of board AVR family from ETT. User can learn
general usage from menu HELP by self, in this case, we
will only mention procedure to setup program
PonyProg2000 for using with all versions Board AVR
family from ETT.
Be carefully, in case of using CPU AVR family
No.ATmega64 because internal structure has many Fuse
Bits to configure condition of CPU operation. These
Fuse Bits are effect on downloading as Serial
Programming Type. In case of selecting Fuse Bit
incorrectly, we can not program CPU by Serial
Programming Type. To solve this problem is modifying
Fuse Bit of CPU by using Parallel Programmer first and
then we can use it as usual.
If we program CPU AVR family with ETT Board and
use Program PonyProg2000, we must configure Option of
program as following;

ETT CO.,LTD -11- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

1. Configure Setup → Interface Setup… as following.

- Select I/O Port to be


Parallel and then select
format of programming to
be Avr ISP I/O.
- Select Printer Port as
truly usage such as LPT1
in case of using Printer
Port LPT1.
- No select in the part of
Polarity Control Line.
- Only setup program for
the first time usage.

2. Command Program PonyProg200 to calculate the


suitable speed for sending signal into CPU, click
Setup → Calibration.

ETT CO.,LTD -12- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual
- We command to Calibration only one time when we use
program in the first time.

3. Select CPU number; click Device → AVR Micro →


such as Atmega64.

4. Select Command → Security and Configuration Bits,


if it is other AVR number, can configure Fuse Bit
as required. User can learn more detailed of Fuse
Bit from Data Sheet of CPU by self. Be carefully,
if using with ATmega64, we must configure Fuse Bit
correctly otherwise we can not program CPU through
Serial Programming Type, we can configure Fuse Bit
as following;

ETT CO.,LTD -13- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

Picture displays configuration of Fuse Bit for using


with CPU No.ATmega64.

The Fuse Bit’s Meaning of ATmega64

‰ If select or tick [√] sign in front of which


Fuse Bit, it means that we configure the Fuse
Bit to be “0” or Command to program Fuse Bit.
‰ If not select or tick [√] sign in front of which
Fuse Bit, it means that we configure Fuse Bit to
be “1” or Command to not program Fuse Bit.

The Fuse Bit’s meaning of ATmega64 that is


effect on Serial programming

• SPIEN: It is Serial Programming Enable Bit. We


must always program this Fuse Bit because we can
program CPU through In-System Serial
Programming. Generally, it is configured by
manufacturer and can not be erased or modified
by Mode Serial Programming. If CPU is programmed
by Parallel Programming, do not forget to
command this Fuse Bit.
• OCDEN and JTAGEN: We use both Fuse Bit to debug
operation of MCU and program through JTAG
Interface and must use with AVR JTAG Debugger.
If we do not use this Fuse Bit for operation, it
is necessary to select both Fuse Bits.
• CKOPT: It is Oscillator Option Bit. If we select
this Fuse Bit, it means that we configure CPU to

ETT CO.,LTD -14- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual
run with frequency 16MHz. If we do not select
this Fuse Bit, we configure CPU to run with
frequency not much than 8 MHz. If we use the
standard ETT Board, we use XTAL to be frequency
generator. So, we should command this Fuse Bit
because CPU can run with frequency XTAL range
1.0MHz-16.0MHz.
• CKSEL3…0: It is Select Clock Source Bit. We use
it to select generator frequency and frequency
range for CPU. If using with standard ETT Board,
must select External Crystal 1.0MHz-16.0MHz but
if we select other value, it makes operation of
program error. Remember, if we select generator
frequency incorrectly such as “External Clock”
or “External RC Oscillator”, it makes CPU can
not run because we do not interface external
Clock and we can not program CPU through Serial
Programming Type. We can solve this problem by
modification Fuse Bit of CPU to be “External
Crystal”.

Generator Frequency AVR To Configure Fuse Bit of CKSEL[3…0]


Atmega64 (0=Program,1=Un-Program)
External Crystal/Ceramic Resonator 1111-1010
External Low Frequency Crystal 1001
External RC Oscillator 1000-0101
Calibrated Internal RC Oscillator 0100-0001
External Clock 0000

Picture displays the selection generator frequency from


Fuse Bit CKSEL [3…0].

ETT CO.,LTD -15- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

NOTE:
- Default value = 1. It means that not program Fuse Bit
and not tick any mark [√] in front of Fuse Bit’ name.
- Default value = 0. It means that command to program
fuse Bit and must tick mark [√] in front of Fuse
Bit’s name.
- Should program Fuse Bit of CKOPT to run with
frequency range 1.0MHz-16.0MHz.
- Do not command to program Fuse Bit of CKSEL[3..0]
because the operation will be error. For example, if
we program all Fuse Bit of CKSEL[3..0] to be “0”,
after program PonyProg200 has already written default
value of Fuse Bit into CPU completely, we can not use
CPU with ETT Board and can not program through Serial
Programming Type. If we program all Fuse Bit of
CKSEL[3..0] to be “0”, it configures CPU to run with
External Clock, so External Crystal stops running and
CPU wait for receiving External Clock only but ETT
Board use only External crystal. So, we must modify
Fuse Bit of CPU by using Parallel first, and then we
can use CPU as usual.
- Fuse Bit’s Position of Lock[2..1] cab be configured
as required.

5. Select Command → Program Option as following;

ETT CO.,LTD -16- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual
6. Open Hex File that we want to program into CPU,
click File → Open Program (FLASH) File… → and
then assign name and address of Hex File.

ETT CO.,LTD -17- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

7. Start to program data into CPU, click Command →


Program. Then program will run as downloaded 5
Commands as following; Load File → Erase → Write
Program memory (FLASH) and Write Security and
Config Bits respectively. In this case, we must
wait for program finished completely.

After programming completely, CPU will start


operation as downloaded data in program instantly.

ETT CO.,LTD -18- WWW.ETT.CO.TH


ET-BASE AVR ATmega64/128 User’s Manual

The basic procedure to check if can not


download program

If there’s error in step of programming, we can


check the problem as following;

ƒ Read User’s Manual of Board and User’s Manual of


Download program AVR by using Program Ponyprog2000
well before using board.
ƒ Check connection of cables and for downloading
program PonyProg2000 must use with Cable Download
version “ET-CAP10PIN” from ETT. We must set Jumper
to be PonyProg correctly (can see more detailed
from page 9).
ƒ Check Power Supply of Board.
ƒ Check default values of program for downloading
Program PonyProg2000.
ƒ Check signal from PORT-PB of CPU is interfaced
with external component while downloading or not.
For example, it is interfaced with LED or
interfaced with other circuit while downloading
data.
ƒ Should not interface Cable RS232 with Port RS-232-
CH0 because SPI Programming of ATmega64 uses Pin
with RS232 (RXD0, TXD0).

ETT CO.,LTD -19- WWW.ETT.CO.TH


Example with AVR Studio 4

An Example with AVR Studio 4


We use AVR Studio 4 for writing Assembly Language
Program because ATMEL Co., Ltd. gives it to customer
without any charge and we can download this program
free from websit : www.atmel.com However, ETT Co.,
Ltd. provides this program in our CD-ROM. It is
program AVR Studio 4 Version 4.12 and proceeding to
use this program is;

1. Open program AVR Studio, it will display window of


Welcome to AVR Studio and then click New project to
create new project as in the picture.

2. Select Project Type as Atmel AVR Assembler for


writing Assembly Language Program and then specify
project name in the blank of Project name. Select
blank of Create initial file to create Assembly File
with Project File, select blank of Create folder to
create folder for saving project file, and then
select directory for saving project file. Lastly,
click Finish as in the picture.

ETT CO.,LTD -1- WWW.ETT.CO.TH


Example with AVR Studio 4

3. It will display window of Text Editor for writing


program as in the picture.

4. Type example of Assembly Language Program and in


the sample, it is program of blinker at PORTB.O.

;*******************************************************
;* Examples Program For "ET-AVR STAMP ATmega64" Board *
;* Target MCU : Atmel ATmega16 *
;* Frequency : X-TAL : 16 MHz *
;* Compiler : AVR Studio 4.12 (AVR Assembler 2) *
;* Create By : ADISAK CHOOCHAN (WWW.ETT.CO.TH) *
;* Last Update : 1/September/2005 *
;* Description : Example LED Blink on Portb.0 *
;*******************************************************

ETT CO.,LTD -2- WWW.ETT.CO.TH


Example with AVR Studio 4

;Connect PB0 to LED1

.include "m64def.inc"

;************************
; Define Register
;************************
.def COUNTER1 = R16
.def COUNTER2 = R17
.def COUNTER3 = R18
.def TEMP = R19

;***********************
; Define I/O Port,Pin
;***********************
.equ LED = 0

;*******************
; Main Program
;*******************
.CSEG
.ORG 0
RJMP RESET ;Reset Handle

RESET: LDI TEMP,LOW(RAMEND);Initial Stack Pointer


OUT SPL,TEMP
LDI TEMP,HIGH(RAMEND)
OUT SPH,TEMP

SBI DDRB,LED ;Config Portb.0 as output

MAIN: SBI PORTB,LED


RCALL DELAY_200ms
CBI PORTB,LED
RCALL DELAY_200MS
RJMP MAIN

;/******************
; Delay time
;/******************
DELAY_1ms: LDI COUNTER1,16
DELAY_1ms_1: LDI COUNTER2,250
DELAY_1ms_2: NOP
DEC COUNTER2
BRNE DELAY_1ms_2
DEC COUNTER1
BRNE DELAY_1ms_1
RET

DELAY_200ms: LDI COUNTER3,200


DELAY_200ms_1: RCALL DELAY_1ms
ETT CO.,LTD -3- WWW.ETT.CO.TH
Example with AVR Studio 4

DEC COUNTER3
BRNE DELAY_200ms_1
RET

5. Translate written program, click Menu Instruction


of Build Æ Build. After translated program completely
without any mistake, it will display a message of 0
errors 0 warning and user can download this HEX File
into MCU instantly.

ETT CO.,LTD -4- WWW.ETT.CO.TH


Example with BASCOM-AVR

An Example with BASCOM-AVR


We use Program BASCOM-AVR for writing BASIC
Language Program. MCS Electronics Co., Ltd. has
experimental version of this Software and user can
download from website : www.mcselec.com However, ETT
Co., Ltd. provides this program in our CD-ROM. It is
program BASCOM-AVR Version 1.11.7.9. but user can not
compile Source Code greater than 4 kbyte and
proceeding to use this program is;

1.Open program CodeVisionAVR C Complier and click


Menu Instruction of File Æ New as in the picture.

2. It will display window of Editor for writing


program. In the sample, it is a program of blinker at
PORTB.O.

ETT CO.,LTD -1- WWW.ETT.CO.TH


Example with BASCOM-AVR

'*******************************************************
'* Examples Program For "ET-AVR STAMP ATmega64" Board *
'* Target MCU : Atmel ATmega16 *
'* Frequency : X-TAL : 16 MHz *
'* Compiler : BASCOM-AVR 1.11.7.9 *
'* Create By : ADISAK CHOOCHAN (WWW.ETT.CO.TH) *
'* Last Update : 1/September/2005 *
'* Description : Example LED Blink on Portb.0 *
'*******************************************************

'Connect PB0 to LED1

$regfile="m64def.dat" 'ATmega16
$crystal=16000000 'X-TAL = 16 MHz

Config Portb=Output 'Config Portc as output

Do
Portb.0 = Not Portb.0 'Convert Portb.0
Waitms 200 'Wait 200 ms
Loop
End

3. Save written BASIC Language program, click Menu


File Æ Save and specify its File name. Click Save as
in the picture.

ETT CO.,LTD -2- WWW.ETT.CO.TH


Example with BASCOM-AVR

4. Select Menu Instruction of Option Æ Compiler Æ


Output to assign default value of Output File
creation into program BASCOM-AVR.

5. Translate written program, click Menu Instruction


of Program Æ Compile. After translated program
completely without any mistake, it will display a
message as No errors found and user can download this
HEX File into MCU instantly.

ETT CO.,LTD -3- WWW.ETT.CO.TH


Example with CodeVisionAVR

An Example with CodeVisionAVR

We use Program CodeVisionAVR for writing C


Language Program. HP InfoTech Co., Ltd. has
experimental version of this Software and user can
download program from website : www.hpinfotech.com
However, ETT Co., Ltd. provides this program in our
CD-ROM. It is program CodeVisionAVR Version 1.24.7e
but user can not compile Source Code greater than 2
kbyte and proceeding to use this program is;

1.Open program CodeVisionAVR C Complier and click


Menu Instruction of File Æ New as in the picture.

2. Select File Type as Source to create new C


Language File and then click OK as in the picture.

ETT CO.,LTD -1- WWW.ETT.CO.TH


Example with CodeVisionAVR

3. It will display window of Editor for writing


program as in the picture. In the sample, it is
program of blinker at PORTB.O.

//**********************************************/;
//*Hardware : ET-AVR STAMP (ATmega64 ) */;
//*CPU : ATMEL-ATmega64 */;
//* X-TAL : 16.00 MHz */;
//* Filename : Main.C */;
//*Complier : CodeVisionAVR V1.24.7d */;
//* Last Update : 9-12-2005 (ETT CO.,LTD) */;
//* : WWW.ETT.CO.TH */;
//*Description : Example LED Blink on Portb.0 */;
//**********************************************/;
//*CodeVisionAVR Complier Option Setting */;
//* Chip type : ATmega64 */;
//* Program type : Application */;
//*Clock frequency : 16.000000MHz */;
//* Memory model : Small */;
//*External SRAM size : 0 */;
//* Data Stack size : 1024 */;
//**********************************************/;

#include <mega64.h> // ATmega64 MCU


#include <delay.h> // Delay functions

void main(void)
{
PORTB=0x00; // PB7..0 = 0
DDRB=0x01; // PB0 = Output

//Loop Blink LED on PB0


while (1)
{
PORTB |= 0x01; // PB0 = 1 (OFF LED)
delay_ms(200); // Display LED Delay
PORTB &= 0xFE; // PB0 = 0 (ON LED)
delay_ms(200); // Display LED Delay
}
}

ETT CO.,LTD -2- WWW.ETT.CO.TH


Example with CodeVisionAVR

4. Save C Language Program, click Menu File Æ Save,


specify its File name and then click Save as in the
picture.

5. Select Menu File Æ New and select File Type as


Project to create new project and then click OK as in
the picture.

6. Click NO because we do not want HELP to create


Project (CodeWizard).

ETT CO.,LTD -3- WWW.ETT.CO.TH


Example with CodeVisionAVR

7. Assign Project Name as required and then click


Save as in the picture.

8. Add written C Language File into project, click


Add as in the picture.

ETT CO.,LTD -4- WWW.ETT.CO.TH


Example with CodeVisionAVR

9. When it is completely, click OK as in the picture.

ETT CO.,LTD -5- WWW.ETT.CO.TH


Example with CodeVisionAVR

10. Assign default values of project, click Menu


Instruction of Project Æ Configure and then assign
MCU No. as ATmega64, Crystal as 16.00000 MHz and File
Output Format(s) as COF ROM HEX EEP.

ETT CO.,LTD -6- WWW.ETT.CO.TH


Example with CodeVisionAVR

11. Translate written program, click Menu Instruction


of Project Æ Make. After translated program
completely without any mistake, it will display a
message No errors, No warning and then user can
download this HEX File into MCU instantly.

ETT CO.,LTD -7- WWW.ETT.CO.TH

Potrebbero piacerti anche