Microcontroller - Peresentation 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

ATmega16 Memories

 In-System Reprogrammable Flash


Program Memory

 The ATmega16 contains 16K bytes On-chip In-


System Reprogrammable Flash memory for
program storage.
 The Flash memory has an endurance of at least
10,000 write/erase cycles. The ATmega16
Program Counter (PC) is 13 bits wide.
ATmega16 Memories

 SRAM Data Memory

 Is divided to 3 section.1120 Data


Memory locations address the Register
File, the I/O Memory, and the internal
data SRAM. The first 96 locations
address the Register File (32 (R0-R31))
and I/O Memory register (64), and the
next 1024 locations address the
internal data SRAM.
ATmega16 Memories

 EEPROM Data Memory


 The ATmega16 contains 512 bytes of data
EEPROM memory. It is organized as a separate
data space, in which single bytes can be read
and written. The EEPROM has an endurance of
at least 100,000 write/erase cycles.
ATmega16 reset sources
 Power-on Reset - The microcontroller is reset when the
supply voltage is less than the Power-on Reset threshold.

 External Reset - The microcontroller is reset when the


RESET pin (the pin number 9) is grounded

 Watchdog System Reset - The microcontroller is reset


when the Watchdog Timer period expires and the Watchdog
System Reset mode is enabled.
Watch dog timer are used to facilitate automatic correction of
hardware faults, and to prevent errant or malevolent software.
During normal operation, the microcontroller regularly restarts
the watchdog timer to prevent it from elapsing, or "timing out“

 Brown-out Reset - The microcontroller is reset when the


supply voltage VCC is less than the Brown-out Reset.
C language review

 C is a middle- level programming language which can be used


for programming of AVR microcontrollers
Some of the advantages of c language to the assembly:
 C syntax is a lot easier to learn than Assembler syntax.
 C is easier to use for making more complex programs.
 C Is a lot more flexible and portable, meaning that by small
changes in the program of particular AVR you can use that
program for another one, it means that the architecture of
the AVR don’t needed for programming, while assembly
instruction depends on the processor architecture.
 Availability of library and functions
Advantage of assembly to c language is that, in using particular
instruction, assembly codes volume is lower than the c language
C language review

 Basic syntax of c language

 first rule involves the use of the semicolon ";" Every


command in C must end with a semi-colon except the
statements which starts with #.
a  a  b;
 Comments are like helping text in your C program and
they are ignored by the compiler. They start with /* and
terminate with the characters */ as shown below :
/* my first program in C */ or //
C language review

 It is possible to write more than one statement in one


line of a program, for Ex:

a  a  b; , c  a  b;

 The program which starts with curly braces ‘{‘ , it must


be enclosed with in that too, for Ex:

switch (var) {
case 1:
doThing1();
break; case 2:
doThing2();
break; }
C language review

 Each variable must be determined before using that


 For determining of the variables; letters, numbers and
also symbols like underline can be used.
 Numerical variables can be determined by these three
ways:
x  225; //Decimal

x  0b1111 1111; //Binary

x  0 xFF ; //Hexadecimal
C language review
 C program basics
C language review
 A sample program
C Review:

 Variable Declaration:
Type Size (Bits) Range
bit 1 0,1
char 8 -128 to 127
unsigned char 8 0 to 255
signed char 8 -128 to 127
int 16 -32768 to 32767
short int 16 -32768 to 32767
unsigned int 16 0 to 65535
signed int 16 -32768 to 32767
C Review:

 Variable Declaration:
Type Size (Bits) Range
long int 32 -2147483648 to 2147483647
unsigned long int 32 0 to 4294967295
signed long int 32 -2147483648 to 2147483647
float 32 ±1.175e-38 to ±3.402e38
double 32 ±1.175e-38 to ±3.402e38

You might also like