In the AVR microcontroller the flash memory is divided into two parts, namely Application Section and Boot Loader Section. A code can be programmed into either the Application Section or the Boot loader Section (BLS). The code programmed into the Application section runs normally and is used for common applications, whereas the code running in the BLS is provided with some special features. The code running in the BLS section can execute Self Programing Mode (SPM) instructions which are blocked for the code running in the Application section. Using SPM instructions the code from the BLS can rewrite the code in the application section or the code in the BLS itself. The BLS section is normally used for storing the Boot-loader code for the microcontroller. The Boot-Loader code can be used for initializing the peripherals in the microcontroller, initialize the devices connected to the microcontroller, select the application to load and execute from a storage medium, load the selected application to the application section, jump to the application section and execute the application.
The AVR flash memory is divided into two sections namely the application section and the Boot-Loader section (BLS). In case of the ATMEGA16 it has 16 KB of flash memory of which the 15KB is application section and the rest 1KB is BLS. The memory architecture of the ATMEGA16 is shown in the following figure;
Fig. 2: Architechure of AVR Flash Memory
FUSE BITS CONFIGURATION
|
|
FUSE
|
VALUE
|
OCDEN
|
1
|
OCD1
|
0
|
JTAGEN
|
0
|
SPIEN
|
1
|
CKPOT
|
1
|
EESAVE
|
0
|
BOOTSZ1
|
0
|
BOOTSZ0
|
0
|
BOOTRST
|
0
|
BODLEVEL
|
1
|
BODEN
|
1
|
SUT1
|
0
|
SUT0
|
0
|
CKSEL3
|
0
|
CKSEL2
|
1
|
CKSEL1
|
0
|
CKSEL0
|
0
|
Project Source Code
###
#define F_CPU 8000000#include <avr/io.h>#include <util/delay.h>int main ( void ){DDRD |= 0x80;PORTD &= 0x7F;_delay_ms ( 500 );PORTD |= 0x80;_delay_ms ( 500 );PORTD &= 0x7F;_delay_ms ( 500 );PORTD |= 0x80;_delay_ms ( 500 );PORTD &= 0x7F;_delay_ms ( 500 );PORTD |= 0x80;_delay_ms ( 500 );PORTD &= 0x7F;_delay_ms ( 500 );PORTD |= 0x80;_delay_ms ( 500 );PORTD &= 0x7F;_delay_ms ( 500 );PORTD |= 0x80;_delay_ms ( 500 );asm ( "jmp 0x0000" );}###
Project Source Code
###
//########## Test-Application##########// #define F_CPU 8000000 #include <avr/io.h> #include <util/delay.h> int main ( void ) { DDRD |= 0x80; while(1) { PORTD &= 0x7F; _delay_ms ( 2000 ); PORTD |= 0x80; _delay_ms ( 2000 ); } }###
Project Components
Project Video
Filed Under: AVR
Filed Under: AVR
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.