Fundamentals of Assembly Language Programming
Instruction to Assembler, Compiler and IDE
C Programming for 8051 Microcontroller
Basic Arithmetic and Logical Programming
Timer and Counter, Interrupts
Interfacing and Programming of Serial Communication, I2C, SPI and CAN of 8051 Microcontroller
1. MT2301
EMBEDDED SYSTEMS AND PROGRAMMING
Dr. K. Kannan, M.E., M.E., Ph.D.,
Professor & Head,
Department of Mechatronics Engineering
2. Preamble
• To familiarize the architecture and
fundamental units of microcontroller.
• To understand the microcontroller
programming methodology
• To acquire the interfacing skills
• To exchange data using various
communication protocols.
3. Unit I – Introduction to Microcontroller (9)
• Fundamentals, Functions of ALU
• Microprocessor, Microcontrollers, CISC and
RISC, Types Microcontroller
• 8051 Family, Architecture, Features and
Specifications
• Memory Organization
• Instruction Sets and Addressing Modes.
4. Unit II – Programming and Communication (9)
Fundamentals of Assembly Language Programming
Instruction to Assembler, Compiler and IDE
C Programming for 8051 Microcontroller
Basic Arithmetic and Logical Programming
Timer and Counter, Interrupts
Interfacing and Programming of Serial Communication, I2C, SPI
and CAN of 8051 Microcontroller
Bluetooth and WI-FI interfacing of 8051 Microcontroller.
5. Unit III – ARM Processor (9)
• Introduction ARM 7 Processor
• Internal Architecture
• Modes of Operations
• Register Set, Instruction Sets
• ARM Thumb, Thumb State Registers
• Pipelining
• Basic programming of ARM 7 - Applications.
7. Unit V – Real Time Operating System (9)
• Real time operating systems Architecture
• Tasks and Task states - Tasks and Data
• Semaphore and shared data
• Message queues, mail boxes and pipes,
• Encapsulating semaphores and queues
• Interrupt routines in an RTOS Environment.
8. Learning Resources
Text Books
1. David E. Simon, An embedded software primer, Addison – Wesley,
Indian Edition Reprint,2009.
2. Kenneth J. Aylala, The 8051 Microcontroller, the Architecture and
Programming Applications, 2003.
Reference Books
1. Muhammad Ali Mazidi and Janice Gillispic Mazdi, The 8051
Microcontroller and Embedded Systems, Pearson Education, 2006.
2. James W. Stewart, The 8051 Microcontroller Hardware, Software and
9. Outcome
CO. No. Course Outcome K-Level
CO1
Explain the various functional units of microcontroller, processors and
system-on-chip based on the features and specifications.
K2
CO2
Recognize the role of each functional units in microcontroller,
processors and system-on-chip based on the features and
specifications.
K2
CO3 Explain the architecture and Instruction set in ARM Processor K2
CO4
Explain the architecture and fundamental operating concepts behind
PIC Microcontroller
K2
CO5
Summarize the basics of Real time operating system and its
applications.
K2
10. Unit II – Programming and Communication (9)
Fundamentals of Assembly Language Programming
Instruction to Assembler, Compiler and IDE
C Programming for 8051 Microcontroller
Basic Arithmetic and Logical Programming
Timer and Counter, Interrupts
Interfacing and Programming of Serial Communication, I2C, SPI
and CAN of 8051 Microcontroller
Bluetooth and WI-FI interfacing of 8051 Microcontroller.
20. Assembler, Compiler & IDE
The difference between compiler and assembler is that a
compiler is used to convert high-level programming language
code into machine language code. On the other hand, an
assembler converts assembly level language code into machine
language code. Both these terms are relevant in context to
program execution.
An integrated development environment (IDE) is a software
application that helps programmers develop software code
efficiently. It increases developer productivity by combining
capabilities such as software editing, building, testing, and
packaging in an easy-to-use application
179. I2C Interfacing
I²C is a serial computer bus, which is invented by NXP
semiconductors (Philips semiconductors). The I²C bus is used
to attach low-speed peripheral integrated circuits to 8051
microcontrollers. I²C bus uses two bidirectional lines such as
SDA (serial data line) and SCl (serial clock line). I²C bus
permits a master device to start communication with a slave
device. Data is interchanged between these two devices.
Typical voltages used are +3.3V or +5V although systems with
extra voltages are allowed. Nowadays new microcontrollers
have inbuilt I²C Registers. But in 8051 there is no such
registers. For the sake of interfacing I²C, EEPROM should be
interfaced with 8051
181. I2C Interfacing
Write Mode
Send the START command from the Master.
Send Device (EEPROM) Address with write mode.
Send Register address in Device (EEPROM)
Send the Data to the Device (EEPROM).
If more than one byte to be send, keep sending that byte.
Finally, Send the STOP command.
Read Mode
Send the START command from the Master.
Send Device (EEPROM) Address with Read mode.
Send Register address in Device (EEPROM)
Send again START command
Send Device address with Reading mode.
Read the data from Device (EEPROM).
Finally, Send the STOP command.
182. I2C Interfacing
Initially, SDA and SCL are High.
SDA first goes to Zero.
Then SCL goes to Zero.
Initially, SDA and SCL are low.
SCL first goes to High.
Then SDA goes to High.
183. Serial Peripheral Interface
Serial bus protocol
Fast, easy to use, and simple
Very widely used
Not “standardized”
A 4-wire communications bus
Typically communicate across short distances
Supports
Single master
Multiple slaves
Synchronized
Communications are “clocked”
184. Serial Peripheral Interface
Always full-duplex
Communicates in both directions simultaneously
Transmitted (or received) data may not be meaningful
Multiple Mbps transmission speeds
0-50 MHz clock speeds not uncommon
Transfer data in 4 to 16 bit characters
Supports multiple slaves
185. Serial Peripheral Interface
MOSI – carries data out of master to slave
MISO – carries data out of slave to master
Both MOSI and MISO are active during every transmission
SS# (or CS) – unique line to select each slave chip
SCLK – produced by master to synchronize transfers
186. Serial Peripheral Interface
SPI uses a “shift register” model of communications
Master shifts out data to Slave, and shifts in data from Slave
187. Serial Peripheral Interface
Two bus configuration models
Master and multiple independent slave
Master and multiple daisy-chained slaves
188. Controller Area Network
CAN is a serial bus system developed to satisfy the following
requirements:
Network multiple microcontrollers with 1 pair of wires.
Allow microcontrollers communicate with each other.
High speed, real-time communication.
Provide noise immunity in an electrically noisy
environment.
Low cost
189. Who uses CANBUS?
• Designed specifically for automotive applications
• Today - industrial automation / medical equipment
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
Automotive Medical / Industrial
Markets
CANBUS Market Distribution
191. CANBUS Physical Layer
Physical medium – two wires terminated at both ends by
resistors.
Differential signal - better noise immunity.
Benefits:
Reduced weight, Reduced cost
Fewer wires = Increased reliability
192. Transmission Characteristics
CAN is a serial, asynchronous, multi-master
communication protocol for connecting control
modules.
CAN supports bit rates in the range of 1Kbps to
1Mbps. The data rate less than 125Kbps normally
known as low speed CAN. Data rate 125Kbps to
1Mbps is known as high speed CAN.
CAN node has its own clock generator for sampling
the incoming data.
193. CAN uses single wire, dual wire or fault tolerant techniques
for signaling.
In single wire CAN data rates are 33.3Kbps and 83.33Kbps
and signaling is single ended.
Dual wire CAN data rates are at high speed CAN and
signaling is differential.
Fault tolerant CAN intended for low speed CAN. If any wire
is shorted to battery or ground, fault tolerant CAN still be
operational.
Binary zero is represented by a "dominant" state in the
bus and binary one by a recessive state.
Transmission Characteristics
194. If the network is idle, any node can send a message. If
two messages are sent simultaneously, the node that
sends a recessive bit, but detects a dominant bit stops
transmitting, leaving the network free for the higher
priority message. The higher priority message is not
corrupted.
Transmission Characteristics
195. Message Oriented Transmission Protocol
• Each node – receiver & transmitter
• A sender of information transmits to all devices on the bus
• All nodes read message, then decide if it is relevant to them
• All nodes verify reception was error-free
• All nodes acknowledge reception
196. Message Format
• Each message has an ID, Data and overhead.
• Data –8 bytes max
• Overhead – start, end, CRC, ACK
198. Bus Arbitration
• Arbitration – needed when multiple nodes try to transmit
at the same time
• Only one transmitter is allowed to transmit at a time.
• A node waits for bus to become idle
• Nodes with more important messages continue
transmitting
199. Bus Arbitration
• Message importance is encoded in message ID.
Lower value = More important
• As a node transmits each bit, it verifies that it sees the same bit value
on the bus that it transmitted.
• A “0” on the bus wins over a “1” on the bus.
• Losing node stops transmitting, winner continues.