KitsAndParts.Com Forum

A place to exchange information about parts and kits supplied by http://kitsandparts.com

You are not logged in.

#1 2010-07-11 21:55:07

w8bh
Member
From: Dayton, OH
Registered: 2010-05-24
Posts: 38

How to use an ATmega328 in your kit

For a few cents more, you can quadruple the amount of microcontroller program memory.  The ATmega328 has 32K of Flash, 1K of EEPROM, and 2K of SRAM.  This chip is pin compatible with your kit's ATmega88, but it requires three changes to your programming.

First, you must program the fuse bytes.  For the '328, they are low=$F7, high=$D7, and extended=$FF.  You must program these bytes with your AVRISP-II programming software.  Note that there are many different values that will work, but there are also values that will 'brick' your microcontroller, rendering it almost inoperable.  There is a nice online fuse calculator at http://www.engbedded.com/fusecalc/

Second, you must use the proper include file in your code.  Instead of the line '.include "m88def.inc"'  you must use '.include "m328def.inc"'  My software didn't have this file, for some reason, but it is easy to find on the internet.

Finally, the size of the interrupt vector table is twice as large in the 328, and all of the rjmp entries in the table must be changed to jmp.  Again, there are several ways to write this table.  Here is one method:

Code:

.cseg 
.org $000
    jmp    RESET
.org Int0addr
    jmp    EXT_INT0       ; External Interrupt Request 0
.org Int1addr
    jmp    EXT_INT1       ; External Interrupt Request 1
.org OVF0addr
    jmp    OVF0           ; Timer/Counter0 Overflow

.org INT_VECTORS_SIZE
RESET: ;init everything here

Do these three things, and your ATmega328 chip will be happy.

Last edited by w8bh (2010-07-11 21:55:57)

Offline

 

Board footer

Powered by FluxBB