Lec 3
Lec 3
Lec 3
Programming
Lecture 3
First Microcontrollers
IBM started using Intel processors in its PC
Intel started its 8042 and 8048 (8-bit
microcontroller) using in printers
Apple Macintosh used Motorola
1980 Intel abandoned microcontroller business
By 1989 Microchip was a major player in
designing microcontrollers
PIC: Peripheral Interface Controller
Microcontroller Unit (MCU)
Block Diagram
16-bit Bus
CPU Allows for different bus widths
Program
Memory
PIC18F Microcontroller Families
PIC microcontrollers are designed using
the Harvard Architecture which includes:
Microprocessor unit (MPU)
Program memory for instructions
Data memory for data
I/O ports
Support devices such as timers
Microcontroller with
the Harvard Architecture
The PIC18F4520 Microcontroller
10
PIC18F4520 Basic Component
11
Block Diagram
Stack
RAM EEPROM
Program
ROM PC
Program Data
Bus Bus
CPU
Interrupt Other
Control OSC Timers Ports
Logic Peripherals
12
MPLAB IDE
&
MCC18
Flowcharting
Flowchart
A graphical
representation of
processes (tasks) to be
performed and the
sequence to be followed
in solving computational
problem
Writing Assembly Programs /
and IDE Structure
M:/Microchip/Project1/proj_name.mcp
Create a Project M:/Microchip/Project2/proj_name.mcp Analyze the problem
...etc.
(understand it and
simplify if possible)
Assembling
*.lst (list) File *.err (Error) File
*.COD
*.HEX
Execute and debug
Known as MPLAB SIM your code
Simulation Uses a simulator on the PC to
execute the program
Not real-time execution
SYMBOL TABLE
LABEL VALUE
BYTE1 000000F2
BYTE2
REG0
00000032
00000000
Identifies all memory
REG1
REG2
00000001
00000002
locations and opcodes in
SAVE
START
0000002E
00000020
the source code
__18F452 00000001
BYTE1 000000F2
BYTE2
REG0
00000032
00000000
Identifies all memory
REG1
REG2
00000001
00000002
locations and opcodes in
SAVE
START
0000002E
00000020
the source code
__18F452 00000001
Messages : opcode
0 reported,
0 suppressed
Hex Code (*.HEX)
:020000040000FA
:0400000010EF00F00D
:10002000F20E006E320E016E002401E3000E026E2D
:020030000300CB
:00000001FF
Viewing Your Code
PROG MEMORY
PROG CODE
STRUCTURE
EEPROM
WATCH
Programming Steps
Simpler Assembler Process
Link Process