SlideShare a Scribd company logo
1 of 42
Vibrant Technologies & Computers
Best Corporate Training In Mumbai
Vibrant Technologies & Computers
Contact us on:
+919892900103 |
info@vibranttechnologies.co.in | www.
Vibranttechnologies.co.in
80C51 Block Diagram
Vibrant Technologies & Computers
Vibrant Technologies & Computers
80C51 Memory
Vibrant Technologies & Computers
8051 Memory
Vibrant Technologies & Computers
The data width is 8 bits
Registers are 8 bits
Addresses are 8 bits
 i.e. addresses for only 256 bytes!
 PC is 16 bits (up to 64K program memory)
 DPTR is 16 bits (for external data - up to 64K)
C types
 char - 8 bits <-- use this if at all possible!
 short - 16 bits
 int - 16 bits
 long - 32 bits
 float - 32 bits
C standard signed/unsigned
Accessing External Memory
Vibrant Technologies & Computers
Program Memory
Vibrant Technologies & Computers
Program and Data memory are separate
Can be internal and/or external
 20K internal flash for the Atmel controller
Read-only
 Instructions
 Constant data
char code table[5] = {‘1’,‘2’,‘3’,‘4’,‘5’} ;
 Compiler uses instructions for moving “immediate” data
External Data Memory
Vibrant Technologies & Computers
External Data - xdata
 Resides off-chip
 Accessed using the DPTR and MOVX instruction
 We will not use xdata
 We will use the SMALL memory model
 all data is on-chip
 limited to only ~128 bytes of data!
Internal Data Memory
Vibrant Technologies & Computers
Internal data memory contains all the processor state
 Lower 128 bytes: registers, general data
 Upper 128 bytes:
 indirectly addressed: 128 bytes, used for the stack (small!)
 directly addressed: 128 bytes for “special” functions
Lower 128 bytes
Vibrant Technologies & Computers
Register banks, bit addressable data, general data
 you can address any register!
 let the C compiler deal with details (for now)
Data Memory Specifiers
Vibrant Technologies & Computers
“data” - first 128 bytes, directly addressed
 the default
“idata” - all 256 bytes, indirectly addressed (slower)
“bdata” - bit-addressable memory
 16 bytes from addresses 0x20 to 0x2F
 128 bit variables max
bit flag1, flag2;
flag1 = (a == b);
 can access as bytes or bits
char bdata flags;
sbit flag0 = flags ^ 0; /* use sbit to “overlay” */
sbit flag7 = flags ^ 7; /* ^ specifies bit */
flags = 0; /* Clear all flags */
flag7 = 1; /* Set one flag */
Upper 128 bytes: SFR area
Vibrant Technologies & Computers
Vibrant Technologies & Computers
Accessing SFRs
Vibrant Technologies & Computers
 The interesting SFRs are bit-addressable
 addresses 0x80, 0x88, 0x90, . . . , 0xF8
 SFRs can be addressed by bit, char or int
sbit EA = 0xAF; /* one of the interrupt enables
sfr Port0 = 0x80; /* Port 0 */
sfr16 Timer2 = 0xCC; /* Timer 2 */
sbit LED0 = Port1 ^ 2; /* Define a port bit */
EA = 1; /* Enable interrupts */
Port0 = 0xff; /* Set all bits in Port 0 to 1
if (Timer2 > 100) . . .
LED0 = 1; /* Turn on one bit in Port 2 */
Ports
Vibrant Technologies & Computers
Port 0 - external memory access
 low address byte/data
Port 2 - external memory access
 high address byte
Port 1 - general purpose I/O
 pins 0, 1 for timer/counter 2
Port 3 - Special features
 0 - RxD: serial input
 1 - TxD: serial output
 2 - INT0: external interrupt
 3 - INT1: external interrupt
 4 - T0: timer/counter 0 external input
 5 - T1: timer/counter 1 external input
 6 - WR: external data memory write strobe
 7 - RD: external data memory read strobe
Ports
Vibrant Technologies & Computers
Ports
Vibrant Technologies & Computers
Port 0 - true bi-directional
Port 1-3 - have internal pullups that will source
current
Output pins:
 Just write 0/1 to the bit/byte
Input pins:
 Output latch must have a 1 (reset state)
 Turns off the pulldown
 pullup must be pulled down by external driver
 Just read the bit/byte
Program Status Word
Vibrant Technologies & Computers
Register set select
Status bits
Instruction Timing
Vibrant Technologies & Computers
One “machine cycle” = 6 states (S1 - S6)
One state = 2 clock cycles
 One “machine cycle” = 12 clock cycles
Instructions take 1 - 4 cycles
 e.g. 1 cycle instructions: ADD, MOV, SETB, NOP
 e.g. 2 cycle instructions: JMP, JZ
 4 cycle instructions: MUL, DIV
Instruction Timing
Vibrant Technologies & Computers
Timers
Vibrant Technologies & Computers
Base 8051 has 2 timers
 we have 3 in the Atmel 89C55
Timer mode
 Increments every machine cycle (12 clock cycles)
Counter mode
 Increments when T0/T1 go from 1 - 0 (external signal)
Access timer value directly
Timer can cause an interrupt
Timer 1 can be used to provide programmable baud rate
for serial communications
Timer/Counter operation
 Mode control register (TMOD)
 Control register (TCON)
Mode Control Register (TMOD)
Vibrant Technologies & Computers
Modes 0-3
GATE - allows external pin to enable timer (e.g.
external pulse)
 0: INT pin not used
 1: counter enabled by INT pin (port 3.2, 3.3)
C/T - indicates timer or counter mode
Timer/Counter Control Register (TCON)
Vibrant Technologies & Computers
TR - enable timer/counter
TF - overflow flag: can cause interrupt
IE/IT - external interrupts and type control
 not related to the timer/counter
Timer/Counter Mode 0
Vibrant Technologies & Computers
Mode 1 same as Mode 0, but uses all 16 bits
Timer/Counter Mode 2
Vibrant Technologies & Computers
8-bit counter, auto-reload on overflow
Timer/Counter Mode 3
Vibrant Technologies & Computers
Applies to Timer/Counter 0
Gives an extra timer
Interrupts
Vibrant Technologies & Computers
Allow parallel tasking
 Interrupt routine runs in “background”
Allow fast, low-overhead interaction with environment
 Don’t have to poll
 Immediate reaction
An automatic function call
 Easy to program
8051 Interrupts
 Serial port - wake up when data arrives/data has left
 Timer 0 overflow
 Timer 1 overflow
 External interrupt 0
 External interrupt 1
Interrupt Vector
Vibrant Technologies & Computers
For each interrupt, which interrupt function to call
In low program addresses
 Hardware generates an LCALL to address in interrupt vector
 Pushes PC (but nothing else) onto the stack
 RETI instruction to return from interrupt
0x00 - Reset PC address
0: 0x03 - External interrupt 0
1: 0x0B - Timer 0
2: 0x13 - External interrupt 1
3: 0x1B - Timer 1
4: 0x23 - Serial line
interrupt
Writing Interrupts in C
Vibrant Technologies & Computers
The C compiler takes care of everything
 Pushing/popping the right registers (PSW, ACC, etc.)
 Generating the RTI instruction
 No arguments/no return values
unsigned int count;
unsigned char second;
void timer0 (void) interrupt 1 using 2 {
if (++count == 4000) {
second++;
count = 0;
}
}
 Timer mode 2
 Reload value = 6
Timer Interrupts
Vibrant Technologies & Computers
Wakeup after N clock cycles, i.e. at a specified time
Wakeup every N clock cycles (auto reload)
 Allows simple task scheduling
 Clients queue function calls for time i
 Interrupt routine calls functions at the right time
Wakeup after N events have occurred on an input
Design Problem 1 - frequency counter
Vibrant Technologies & Computers
Measure the frequency of an external signal
Display as a number using the 7-segment display
 e.g. number represents exponent of 2 or 10
Example Timer Setup
Vibrant Technologies & Computers
What does this setup do?
TMOD = 0x62; // 01100010;
TCON = 0x50; // 01010000;
TH1 = 246;
TH0 = 6;
IE = 0x8A; // 10001010;
Using the timers
Vibrant Technologies & Computers
void counterInterrupt ( void ) interrupt 3 using 1 {
timeLow = TL0;
TL0 = 0;
timeHigh = count;
count = 0;
if (timeHigh == 0 && timeLow < 10) *ledaddress = 0x6f;
else if (timeHigh == 0 && timeLow < 100) *ledaddress = 0x6b;
else if (timeHigh < 4) *ledaddress = 0x02;
else if (timeHigh < 40) *ledaddress = 0x04;
else if (timeHigh < 400) *ledaddress = 0x08;
else if (timeHigh < 4000) *ledaddress = 0x10;
else if (timeHigh < 40000) *ledaddress = 0x20;
else *ledaddress = 0xf0; // default
}
void timerInterrupt ( void ) interrupt 1 using 1 {
count++;
}
Design Problem 2 - Measure the pulse width
Vibrant Technologies & Computers
Problem: send several bits of data with one wire
 Serial data
 precise, but complicated protocol
 Pulse width
 precise enough for many sensors
 simple measurement
Design Problem 3 - Accelerometer Interface
Vibrant Technologies & Computers
Accelerometer
 Two signals, one for each dimension
 Acceleration coded as the duty cycle
 pulse-width/cycle-length
 cycle time = 1ms - 10ms (controlled by resistor)
 1ms gives faster sampling
 10ms gives more accurate data
Controlling Interrupts: Enables and Priority
Vibrant Technologies & Computers
Interrupt Controls
Vibrant Technologies & Computers
Interrupt Priorities
Vibrant Technologies & Computers
Two levels of priority
 Set an interrupt priority using the interrupt priority register
 A high-priority interrupt can interrupt an low-priority interrupt
routine
 In no other case is an interrupt allowed
 An interrupt routine can always disable interrupts explicitly
 But you don’t want to do this
Priority chain within priority levels
 Choose a winner if two interrupts happen simultaneously
 Order shown on previous page
Re-entrant Functions
Vibrant Technologies & Computers
A function can be called simultaneously be different
processes
Recursive functions must be re-entrant
Functions called by interrupt code and non-interrupt code
must be re-entrant
Keil C functions by default are not re-entrant
 Does not use the stack for everything
 Use the reentrant specifier to make a function re-entrant
int calc (char i, int b) reentrant {
int x;
x = table[i];
return (x * b);
}
External Interrupts
Vibrant Technologies & Computers
Can interrupt using the INT0 or INT1 pins (port 3:
pin 2,3)
 Interrupt on level or falling edge of signal (TCON specifies
which)
 Pin is sampled once every 12 clock cycles
 for interrupt on edge, signal must be high 12 cycles, low 12 cycles
 Response time takes at least 3 instuctions cycles
 1 to sample
 2 for call to interrupt routine
 more if a long instruction is in progress (up to 6 more)
Thank you
Vibrant Technologies & Computers

More Related Content

What's hot

Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Alexander Bolshev
 
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardProgramming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardGaurav Verma
 
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
AVR_Course_Day6 external hardware  interrupts and analogue to digital converterAVR_Course_Day6 external hardware  interrupts and analogue to digital converter
AVR_Course_Day6 external hardware interrupts and analogue to digital converterMohamed Ali
 
Interrupts at AVR
Interrupts at AVRInterrupts at AVR
Interrupts at AVRHamdy Fouad
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filtersJyotirmaya Mahanta
 
AVR Micro controller Interfacing
AVR Micro controller Interfacing AVR Micro controller Interfacing
AVR Micro controller Interfacing Raghav Shetty
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollersMAIYO JOSPHAT
 
L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2rsamurti
 
AVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerAVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerMohamed Ali
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailedAnkita Tiwari
 
Microcontroller
MicrocontrollerMicrocontroller
MicrocontrollerSpitiq
 
Atmel and pic microcontroller
Atmel and pic microcontrollerAtmel and pic microcontroller
Atmel and pic microcontrollerTearsome Llantada
 
Interfacing with Atmega 16
Interfacing with Atmega 16Interfacing with Atmega 16
Interfacing with Atmega 16Ramadan Ramadan
 

What's hot (20)

Assembler4
Assembler4Assembler4
Assembler4
 
Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...
 
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardProgramming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
 
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
AVR_Course_Day6 external hardware  interrupts and analogue to digital converterAVR_Course_Day6 external hardware  interrupts and analogue to digital converter
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
 
Arduino 101
Arduino 101Arduino 101
Arduino 101
 
Interrupts at AVR
Interrupts at AVRInterrupts at AVR
Interrupts at AVR
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filters
 
AVR Micro controller Interfacing
AVR Micro controller Interfacing AVR Micro controller Interfacing
AVR Micro controller Interfacing
 
ATmega 16
ATmega 16ATmega 16
ATmega 16
 
Introduction to Microcontrollers
Introduction to MicrocontrollersIntroduction to Microcontrollers
Introduction to Microcontrollers
 
STM32 MCU Family
STM32 MCU FamilySTM32 MCU Family
STM32 MCU Family
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollers
 
L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2L9 understanding-atmega328 p-2
L9 understanding-atmega328 p-2
 
89c5131datasheet
89c5131datasheet89c5131datasheet
89c5131datasheet
 
Lecture 2 timers, pwm, state machine IN PIC
Lecture 2   timers, pwm, state machine IN PIC Lecture 2   timers, pwm, state machine IN PIC
Lecture 2 timers, pwm, state machine IN PIC
 
AVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerAVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontroller
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
Atmel and pic microcontroller
Atmel and pic microcontrollerAtmel and pic microcontroller
Atmel and pic microcontroller
 
Interfacing with Atmega 16
Interfacing with Atmega 16Interfacing with Atmega 16
Interfacing with Atmega 16
 

Viewers also liked

Selenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbaiSelenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbaiUnmesh Baile
 
Weblogic-clustering-failover-and-load-balancing-training
Weblogic-clustering-failover-and-load-balancing-trainingWeblogic-clustering-failover-and-load-balancing-training
Weblogic-clustering-failover-and-load-balancing-trainingUnmesh Baile
 
Professional dataware-housing-training-in-mumbai
Professional dataware-housing-training-in-mumbaiProfessional dataware-housing-training-in-mumbai
Professional dataware-housing-training-in-mumbaiUnmesh Baile
 
Hadoop professional-software-development-course-in-mumbai
Hadoop professional-software-development-course-in-mumbaiHadoop professional-software-development-course-in-mumbai
Hadoop professional-software-development-course-in-mumbaiUnmesh Baile
 
Corporate-data-warehousing-training
Corporate-data-warehousing-trainingCorporate-data-warehousing-training
Corporate-data-warehousing-trainingUnmesh Baile
 
Corporate-training-for-msbi-course-in-mumbai
Corporate-training-for-msbi-course-in-mumbaiCorporate-training-for-msbi-course-in-mumbai
Corporate-training-for-msbi-course-in-mumbaiUnmesh Baile
 
Hadoop-professional-software-development-course-in-mumbai
Hadoop-professional-software-development-course-in-mumbaiHadoop-professional-software-development-course-in-mumbai
Hadoop-professional-software-development-course-in-mumbaiUnmesh Baile
 
Big-data-analysis-training-in-mumbai
Big-data-analysis-training-in-mumbaiBig-data-analysis-training-in-mumbai
Big-data-analysis-training-in-mumbaiUnmesh Baile
 
Advance-excel-professional-trainer-in-mumbai
Advance-excel-professional-trainer-in-mumbaiAdvance-excel-professional-trainer-in-mumbai
Advance-excel-professional-trainer-in-mumbaiUnmesh Baile
 
Robotics corporate-training-in-mumbai
Robotics corporate-training-in-mumbaiRobotics corporate-training-in-mumbai
Robotics corporate-training-in-mumbaiUnmesh Baile
 
Microsoft-business-intelligence-training-in-mumbai
Microsoft-business-intelligence-training-in-mumbaiMicrosoft-business-intelligence-training-in-mumbai
Microsoft-business-intelligence-training-in-mumbaiUnmesh Baile
 
Best-robotics-training-in-mumbai
Best-robotics-training-in-mumbaiBest-robotics-training-in-mumbai
Best-robotics-training-in-mumbaiUnmesh Baile
 
Linux-training-for-beginners-in-mumbai
Linux-training-for-beginners-in-mumbaiLinux-training-for-beginners-in-mumbai
Linux-training-for-beginners-in-mumbaiUnmesh Baile
 
Sas-training-in-mumbai
Sas-training-in-mumbaiSas-training-in-mumbai
Sas-training-in-mumbaiUnmesh Baile
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaiUnmesh Baile
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiUnmesh Baile
 
R-programming-training-in-mumbai
R-programming-training-in-mumbaiR-programming-training-in-mumbai
R-programming-training-in-mumbaiUnmesh Baile
 

Viewers also liked (17)

Selenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbaiSelenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbai
 
Weblogic-clustering-failover-and-load-balancing-training
Weblogic-clustering-failover-and-load-balancing-trainingWeblogic-clustering-failover-and-load-balancing-training
Weblogic-clustering-failover-and-load-balancing-training
 
Professional dataware-housing-training-in-mumbai
Professional dataware-housing-training-in-mumbaiProfessional dataware-housing-training-in-mumbai
Professional dataware-housing-training-in-mumbai
 
Hadoop professional-software-development-course-in-mumbai
Hadoop professional-software-development-course-in-mumbaiHadoop professional-software-development-course-in-mumbai
Hadoop professional-software-development-course-in-mumbai
 
Corporate-data-warehousing-training
Corporate-data-warehousing-trainingCorporate-data-warehousing-training
Corporate-data-warehousing-training
 
Corporate-training-for-msbi-course-in-mumbai
Corporate-training-for-msbi-course-in-mumbaiCorporate-training-for-msbi-course-in-mumbai
Corporate-training-for-msbi-course-in-mumbai
 
Hadoop-professional-software-development-course-in-mumbai
Hadoop-professional-software-development-course-in-mumbaiHadoop-professional-software-development-course-in-mumbai
Hadoop-professional-software-development-course-in-mumbai
 
Big-data-analysis-training-in-mumbai
Big-data-analysis-training-in-mumbaiBig-data-analysis-training-in-mumbai
Big-data-analysis-training-in-mumbai
 
Advance-excel-professional-trainer-in-mumbai
Advance-excel-professional-trainer-in-mumbaiAdvance-excel-professional-trainer-in-mumbai
Advance-excel-professional-trainer-in-mumbai
 
Robotics corporate-training-in-mumbai
Robotics corporate-training-in-mumbaiRobotics corporate-training-in-mumbai
Robotics corporate-training-in-mumbai
 
Microsoft-business-intelligence-training-in-mumbai
Microsoft-business-intelligence-training-in-mumbaiMicrosoft-business-intelligence-training-in-mumbai
Microsoft-business-intelligence-training-in-mumbai
 
Best-robotics-training-in-mumbai
Best-robotics-training-in-mumbaiBest-robotics-training-in-mumbai
Best-robotics-training-in-mumbai
 
Linux-training-for-beginners-in-mumbai
Linux-training-for-beginners-in-mumbaiLinux-training-for-beginners-in-mumbai
Linux-training-for-beginners-in-mumbai
 
Sas-training-in-mumbai
Sas-training-in-mumbaiSas-training-in-mumbai
Sas-training-in-mumbai
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbai
 
R-programming-training-in-mumbai
R-programming-training-in-mumbaiR-programming-training-in-mumbai
R-programming-training-in-mumbai
 

Similar to Best-embedded-corporate-training-in-mumbai

MicrocontrollersII.ppt
MicrocontrollersII.pptMicrocontrollersII.ppt
MicrocontrollersII.pptSatheeshMECE
 
introduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.pptintroduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.pptjaychoudhary37
 
Microcontrollers ii
Microcontrollers iiMicrocontrollers ii
Microcontrollers iiKumar Kumar
 
8051 microcontroller and it’s interface
8051 microcontroller and it’s interface8051 microcontroller and it’s interface
8051 microcontroller and it’s interfaceAbhishek Choksi
 
Advanced Embedded Automatic Car Parking System
	Advanced Embedded Automatic Car Parking System	Advanced Embedded Automatic Car Parking System
Advanced Embedded Automatic Car Parking Systemtheijes
 
8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti 8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti VenkatraoRamisetti
 
Embeded system by Mitesh Kumar
Embeded system by Mitesh KumarEmbeded system by Mitesh Kumar
Embeded system by Mitesh KumarMitesh Kumar
 
Embedded Systems,Embedded Systems Project,Winter training,
Embedded Systems,Embedded Systems Project,Winter training,Embedded Systems,Embedded Systems Project,Winter training,
Embedded Systems,Embedded Systems Project,Winter training,Technogroovy
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorialFutura infotech
 
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. Kaware
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. KawareMicroprocessor & Interfacing (Part-2) By Er. Swapnil V. Kaware
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. KawareProf. Swapnil V. Kaware
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollersBarER4
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and RoboticsNIT Raipur
 
Embedded Systems using Microwave oven
Embedded Systems using  Microwave ovenEmbedded Systems using  Microwave oven
Embedded Systems using Microwave ovenBOOMIKAD
 
Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)Vishalya Dulam
 
unit 2 lect 6 AND 7 8254.pptx
unit 2 lect 6 AND 7 8254.pptxunit 2 lect 6 AND 7 8254.pptx
unit 2 lect 6 AND 7 8254.pptxDrVikasMahor
 

Similar to Best-embedded-corporate-training-in-mumbai (20)

MicrocontrollersII.ppt
MicrocontrollersII.pptMicrocontrollersII.ppt
MicrocontrollersII.ppt
 
introduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.pptintroduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.ppt
 
Microcontrollers ii
Microcontrollers iiMicrocontrollers ii
Microcontrollers ii
 
8051 microcontroller and it’s interface
8051 microcontroller and it’s interface8051 microcontroller and it’s interface
8051 microcontroller and it’s interface
 
Advanced Embedded Automatic Car Parking System
	Advanced Embedded Automatic Car Parking System	Advanced Embedded Automatic Car Parking System
Advanced Embedded Automatic Car Parking System
 
unit-2.pptx
unit-2.pptxunit-2.pptx
unit-2.pptx
 
8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti 8051 Microcontroller Overview by Venkatrao Ramisetti
8051 Microcontroller Overview by Venkatrao Ramisetti
 
Embeded system by Mitesh Kumar
Embeded system by Mitesh KumarEmbeded system by Mitesh Kumar
Embeded system by Mitesh Kumar
 
Embedded Systems,Embedded Systems Project,Winter training,
Embedded Systems,Embedded Systems Project,Winter training,Embedded Systems,Embedded Systems Project,Winter training,
Embedded Systems,Embedded Systems Project,Winter training,
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorial
 
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. Kaware
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. KawareMicroprocessor & Interfacing (Part-2) By Er. Swapnil V. Kaware
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. Kaware
 
lesson01.ppt
lesson01.pptlesson01.ppt
lesson01.ppt
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollers
 
Embedded system
Embedded  systemEmbedded  system
Embedded system
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
Embedded Systems using Microwave oven
Embedded Systems using  Microwave ovenEmbedded Systems using  Microwave oven
Embedded Systems using Microwave oven
 
digital clock atmega16
digital clock atmega16digital clock atmega16
digital clock atmega16
 
Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)Pc based wire less data aquisition system using rf(1)
Pc based wire less data aquisition system using rf(1)
 
8051
80518051
8051
 
unit 2 lect 6 AND 7 8254.pptx
unit 2 lect 6 AND 7 8254.pptxunit 2 lect 6 AND 7 8254.pptx
unit 2 lect 6 AND 7 8254.pptx
 

More from Unmesh Baile

Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbaiUnmesh Baile
 
Java course-in-mumbai
Java course-in-mumbaiJava course-in-mumbai
Java course-in-mumbaiUnmesh Baile
 
Linux corporate-training-in-mumbai
Linux corporate-training-in-mumbaiLinux corporate-training-in-mumbai
Linux corporate-training-in-mumbaiUnmesh Baile
 
Corporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbaiCorporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbaiUnmesh Baile
 
Corporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbaiCorporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbaiUnmesh Baile
 
Best-embedded-system-classes-in-mumbai
Best-embedded-system-classes-in-mumbaiBest-embedded-system-classes-in-mumbai
Best-embedded-system-classes-in-mumbaiUnmesh Baile
 

More from Unmesh Baile (6)

Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbai
 
Java course-in-mumbai
Java course-in-mumbaiJava course-in-mumbai
Java course-in-mumbai
 
Linux corporate-training-in-mumbai
Linux corporate-training-in-mumbaiLinux corporate-training-in-mumbai
Linux corporate-training-in-mumbai
 
Corporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbaiCorporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbai
 
Corporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbaiCorporate-informatica-training-in-mumbai
Corporate-informatica-training-in-mumbai
 
Best-embedded-system-classes-in-mumbai
Best-embedded-system-classes-in-mumbaiBest-embedded-system-classes-in-mumbai
Best-embedded-system-classes-in-mumbai
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Best-embedded-corporate-training-in-mumbai

  • 2. Best Corporate Training In Mumbai Vibrant Technologies & Computers Contact us on: +919892900103 | info@vibranttechnologies.co.in | www. Vibranttechnologies.co.in
  • 3. 80C51 Block Diagram Vibrant Technologies & Computers
  • 6. 8051 Memory Vibrant Technologies & Computers The data width is 8 bits Registers are 8 bits Addresses are 8 bits  i.e. addresses for only 256 bytes!  PC is 16 bits (up to 64K program memory)  DPTR is 16 bits (for external data - up to 64K) C types  char - 8 bits <-- use this if at all possible!  short - 16 bits  int - 16 bits  long - 32 bits  float - 32 bits C standard signed/unsigned
  • 7. Accessing External Memory Vibrant Technologies & Computers
  • 8. Program Memory Vibrant Technologies & Computers Program and Data memory are separate Can be internal and/or external  20K internal flash for the Atmel controller Read-only  Instructions  Constant data char code table[5] = {‘1’,‘2’,‘3’,‘4’,‘5’} ;  Compiler uses instructions for moving “immediate” data
  • 9. External Data Memory Vibrant Technologies & Computers External Data - xdata  Resides off-chip  Accessed using the DPTR and MOVX instruction  We will not use xdata  We will use the SMALL memory model  all data is on-chip  limited to only ~128 bytes of data!
  • 10. Internal Data Memory Vibrant Technologies & Computers Internal data memory contains all the processor state  Lower 128 bytes: registers, general data  Upper 128 bytes:  indirectly addressed: 128 bytes, used for the stack (small!)  directly addressed: 128 bytes for “special” functions
  • 11. Lower 128 bytes Vibrant Technologies & Computers Register banks, bit addressable data, general data  you can address any register!  let the C compiler deal with details (for now)
  • 12. Data Memory Specifiers Vibrant Technologies & Computers “data” - first 128 bytes, directly addressed  the default “idata” - all 256 bytes, indirectly addressed (slower) “bdata” - bit-addressable memory  16 bytes from addresses 0x20 to 0x2F  128 bit variables max bit flag1, flag2; flag1 = (a == b);  can access as bytes or bits char bdata flags; sbit flag0 = flags ^ 0; /* use sbit to “overlay” */ sbit flag7 = flags ^ 7; /* ^ specifies bit */ flags = 0; /* Clear all flags */ flag7 = 1; /* Set one flag */
  • 13. Upper 128 bytes: SFR area Vibrant Technologies & Computers
  • 15. Accessing SFRs Vibrant Technologies & Computers  The interesting SFRs are bit-addressable  addresses 0x80, 0x88, 0x90, . . . , 0xF8  SFRs can be addressed by bit, char or int sbit EA = 0xAF; /* one of the interrupt enables sfr Port0 = 0x80; /* Port 0 */ sfr16 Timer2 = 0xCC; /* Timer 2 */ sbit LED0 = Port1 ^ 2; /* Define a port bit */ EA = 1; /* Enable interrupts */ Port0 = 0xff; /* Set all bits in Port 0 to 1 if (Timer2 > 100) . . . LED0 = 1; /* Turn on one bit in Port 2 */
  • 16. Ports Vibrant Technologies & Computers Port 0 - external memory access  low address byte/data Port 2 - external memory access  high address byte Port 1 - general purpose I/O  pins 0, 1 for timer/counter 2 Port 3 - Special features  0 - RxD: serial input  1 - TxD: serial output  2 - INT0: external interrupt  3 - INT1: external interrupt  4 - T0: timer/counter 0 external input  5 - T1: timer/counter 1 external input  6 - WR: external data memory write strobe  7 - RD: external data memory read strobe
  • 18. Ports Vibrant Technologies & Computers Port 0 - true bi-directional Port 1-3 - have internal pullups that will source current Output pins:  Just write 0/1 to the bit/byte Input pins:  Output latch must have a 1 (reset state)  Turns off the pulldown  pullup must be pulled down by external driver  Just read the bit/byte
  • 19. Program Status Word Vibrant Technologies & Computers Register set select Status bits
  • 20. Instruction Timing Vibrant Technologies & Computers One “machine cycle” = 6 states (S1 - S6) One state = 2 clock cycles  One “machine cycle” = 12 clock cycles Instructions take 1 - 4 cycles  e.g. 1 cycle instructions: ADD, MOV, SETB, NOP  e.g. 2 cycle instructions: JMP, JZ  4 cycle instructions: MUL, DIV
  • 22. Timers Vibrant Technologies & Computers Base 8051 has 2 timers  we have 3 in the Atmel 89C55 Timer mode  Increments every machine cycle (12 clock cycles) Counter mode  Increments when T0/T1 go from 1 - 0 (external signal) Access timer value directly Timer can cause an interrupt Timer 1 can be used to provide programmable baud rate for serial communications Timer/Counter operation  Mode control register (TMOD)  Control register (TCON)
  • 23. Mode Control Register (TMOD) Vibrant Technologies & Computers Modes 0-3 GATE - allows external pin to enable timer (e.g. external pulse)  0: INT pin not used  1: counter enabled by INT pin (port 3.2, 3.3) C/T - indicates timer or counter mode
  • 24. Timer/Counter Control Register (TCON) Vibrant Technologies & Computers TR - enable timer/counter TF - overflow flag: can cause interrupt IE/IT - external interrupts and type control  not related to the timer/counter
  • 25. Timer/Counter Mode 0 Vibrant Technologies & Computers Mode 1 same as Mode 0, but uses all 16 bits
  • 26. Timer/Counter Mode 2 Vibrant Technologies & Computers 8-bit counter, auto-reload on overflow
  • 27. Timer/Counter Mode 3 Vibrant Technologies & Computers Applies to Timer/Counter 0 Gives an extra timer
  • 28. Interrupts Vibrant Technologies & Computers Allow parallel tasking  Interrupt routine runs in “background” Allow fast, low-overhead interaction with environment  Don’t have to poll  Immediate reaction An automatic function call  Easy to program 8051 Interrupts  Serial port - wake up when data arrives/data has left  Timer 0 overflow  Timer 1 overflow  External interrupt 0  External interrupt 1
  • 29. Interrupt Vector Vibrant Technologies & Computers For each interrupt, which interrupt function to call In low program addresses  Hardware generates an LCALL to address in interrupt vector  Pushes PC (but nothing else) onto the stack  RETI instruction to return from interrupt 0x00 - Reset PC address 0: 0x03 - External interrupt 0 1: 0x0B - Timer 0 2: 0x13 - External interrupt 1 3: 0x1B - Timer 1 4: 0x23 - Serial line interrupt
  • 30. Writing Interrupts in C Vibrant Technologies & Computers The C compiler takes care of everything  Pushing/popping the right registers (PSW, ACC, etc.)  Generating the RTI instruction  No arguments/no return values unsigned int count; unsigned char second; void timer0 (void) interrupt 1 using 2 { if (++count == 4000) { second++; count = 0; } }  Timer mode 2  Reload value = 6
  • 31. Timer Interrupts Vibrant Technologies & Computers Wakeup after N clock cycles, i.e. at a specified time Wakeup every N clock cycles (auto reload)  Allows simple task scheduling  Clients queue function calls for time i  Interrupt routine calls functions at the right time Wakeup after N events have occurred on an input
  • 32. Design Problem 1 - frequency counter Vibrant Technologies & Computers Measure the frequency of an external signal Display as a number using the 7-segment display  e.g. number represents exponent of 2 or 10
  • 33. Example Timer Setup Vibrant Technologies & Computers What does this setup do? TMOD = 0x62; // 01100010; TCON = 0x50; // 01010000; TH1 = 246; TH0 = 6; IE = 0x8A; // 10001010;
  • 34. Using the timers Vibrant Technologies & Computers void counterInterrupt ( void ) interrupt 3 using 1 { timeLow = TL0; TL0 = 0; timeHigh = count; count = 0; if (timeHigh == 0 && timeLow < 10) *ledaddress = 0x6f; else if (timeHigh == 0 && timeLow < 100) *ledaddress = 0x6b; else if (timeHigh < 4) *ledaddress = 0x02; else if (timeHigh < 40) *ledaddress = 0x04; else if (timeHigh < 400) *ledaddress = 0x08; else if (timeHigh < 4000) *ledaddress = 0x10; else if (timeHigh < 40000) *ledaddress = 0x20; else *ledaddress = 0xf0; // default } void timerInterrupt ( void ) interrupt 1 using 1 { count++; }
  • 35. Design Problem 2 - Measure the pulse width Vibrant Technologies & Computers Problem: send several bits of data with one wire  Serial data  precise, but complicated protocol  Pulse width  precise enough for many sensors  simple measurement
  • 36. Design Problem 3 - Accelerometer Interface Vibrant Technologies & Computers Accelerometer  Two signals, one for each dimension  Acceleration coded as the duty cycle  pulse-width/cycle-length  cycle time = 1ms - 10ms (controlled by resistor)  1ms gives faster sampling  10ms gives more accurate data
  • 37. Controlling Interrupts: Enables and Priority Vibrant Technologies & Computers
  • 39. Interrupt Priorities Vibrant Technologies & Computers Two levels of priority  Set an interrupt priority using the interrupt priority register  A high-priority interrupt can interrupt an low-priority interrupt routine  In no other case is an interrupt allowed  An interrupt routine can always disable interrupts explicitly  But you don’t want to do this Priority chain within priority levels  Choose a winner if two interrupts happen simultaneously  Order shown on previous page
  • 40. Re-entrant Functions Vibrant Technologies & Computers A function can be called simultaneously be different processes Recursive functions must be re-entrant Functions called by interrupt code and non-interrupt code must be re-entrant Keil C functions by default are not re-entrant  Does not use the stack for everything  Use the reentrant specifier to make a function re-entrant int calc (char i, int b) reentrant { int x; x = table[i]; return (x * b); }
  • 41. External Interrupts Vibrant Technologies & Computers Can interrupt using the INT0 or INT1 pins (port 3: pin 2,3)  Interrupt on level or falling edge of signal (TCON specifies which)  Pin is sampled once every 12 clock cycles  for interrupt on edge, signal must be high 12 cycles, low 12 cycles  Response time takes at least 3 instuctions cycles  1 to sample  2 for call to interrupt routine  more if a long instruction is in progress (up to 6 more)