AMESunit.no.1modified
AMESunit.no.1modified
ADVANCED MICROCONTROLLER
AND
EMBEDDED SYSTEM
UNIT NO.1
PIC ARCHITECTURE AND
EMBEDDED C
SUBJECT DETAILS
Teaching Scheme
Theory -03 Hr/Week
Credits -TH -03
Examination Scheme
ISE -30 Marks
ESE -70 Marks
PREREQUISITE
1. Knowledge of Number system and Basic logic
components.
2. Programming basics of C language.
3. Advantage of Microcontroller over
Microprocessor.
CONTENTS
❖ Comparison of CISC and RISC Architectures
❖ Data and Program memory organization
❖ Program Counters
❖ Stack pointer
❖ Bank Select Register
❖ Status register
❖ Embedded C concepts
❖ Header and source files and pre-processor
directives
❖ Data types, data structures, Control loops,
functions, bit operations.
WHAT IS A MICROCONTROLLER?
CLASSIFICATION OF
MICROCONTROLLERS
IMPORTANCE OF ARCHITECTURE
The Central processing unit, referring to both
microprocessor and microcontroller, performs specific tasks with the
help of a Control Unit (CU) and Arithmetic Logical Unit (ALU).
As the instructions are delivered from RAM, the CPU acts with the help
of its two helping units by creating variables and assigning them
values and memory.
It’s really important to know how the CPU performs all this action with
the help of its architecture.
Every CPU has a memory associated with it to store the program and
data. Program and data work with the CPU to get the output. The
Program provides the instruction while the data provides the
information to be worked upon.
VON NEUMANN ARCHITECTURE
The Von Neumann Model uses a single storage structure called
memory for instructions and data. So, the CPU can process either
instructions or data one at a time.
A single bus for getting the code and data means, they come to get
in each other’s way and slow down the processing speed of the
CPU because each had to wait for the other to finish the fetching.
HARVARD ARCHITECTURE
The Harvard architecture has physically separate memory units and
buses for instructions and data. So, the CPU can access data while
the execution of an instruction. Thus ,Harvard computers are faster
than that of computers designed in Von Neumann architecture.
In this architecture a separate data buses for data and program are
present. So it means this architecture proposed the use of four
buses
1. A set of data bus carrying the data into and out of the CPU.
2. A set of address bus for accessing the data.
3. A set of data bus for carrying code into the CPU.
4. An address bus for accessing the code.
WHY CISC & RISC ?
In addition CPU designers added more and complex instructions.
The design of control unit and the instructions decoder became
very complex, occupying more than 50% of the chip area.
This left less space for registers ,resulting in the reduction of the
number of registers on the chip.Therefore to execute the code
MPU needed to access memory more frequently which slowed
execution.
Due to which CISC(complex Instruction set computing or computers
design came into picture.
Researchers then realised that programs uses 20% of the
instructions frequently and remaining 80% is used rarely. Hence
a new philosophy came into the picture
CISC VS RISC
File register
Data
storage Scratchpad Registers
SFR GPR
SFR
Program Counter(PC)
PC The maximum size of the PIC18F’s PC (Program
Counter) is 21-bit wide.
The size of the PC varies from one PIC18F family member to
another. For example, the size of the PC of the PIC18F4321 is
13-bit wide.
The PC normally points to the next instruction.
the 21-bit PC provides the PIC18F with direct addressing
capability of a maximum of 2MB (2) of program memory.
Upon hardware reset, the PC is loaded with zero so that the
PIC18F CPU fetches the first instruction from address 0.
The 21-bit PC is comprised of three 8-bit registers, namely PCL
(PC Low byte), PCLATH (PC latch High byte), and PCLATU (PC
Latch Upper 5 bits).
The 21-bit PC is stored in these registers as follows: bits 0
through 7 in PCL, bits 8 through 15 in PCLATH,
and bits 16 through 20 in the low five bits of PCATU.
Registers PCL, PLATCH, and PCLATU are mapped as special
function registers in the data SRAM by the PIC18F.
File Select Register(FSR)
3.) Declarations:
● The “int i” is a data declaration for the variable named with the
identifier
● int indicates the variable is an integer.
B.] Expressions
Expressions are some combination of constants, variables,
operators, and function calls.
Expressions always have a resulting value.
Some simple examples of an operator are + -*/ and the very
special =
The data types in C language include char, int, float, and double.
A variable declared as a char (character) usually holds eight bits of
data.
A variable of int (integer) type, on the other hand, can hold 16 or
32 bits of data.
The type float specifies a 32-bit single precision floating point
number.
The type double can be used to declare a data as a 64-bit double
precision floating point number.
I.] char are two types: A.Unsigned char(0 to
255)
B.
Signed char(-128 to +127)
II.] int are two types: A.Unsigned char(0 to
65535)
B.
Signed char(- 32,768 to + 32767)