Real Time Interrupts Section 4.15. Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts.

Slides:



Advertisements
Similar presentations
UBI >> Contents Chapter 7 Timers Laboratories MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior (PT) Pedro Dinis Gaspar,
Advertisements

Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Real-Time Library: RTX
4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
Microcontroller Programming II MP6-1
C Examples 1.
8253/54 Timer Section /54 Timer Description and Initialization
Chapter 6 Interrupts and Resets
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
Architecture of the 8051 INTERNAL DATA BUS Oscillator & Timing Programmable I/O (32 Pins) 80C51 CPU 64K byte Expansion Control Serial I/O 4K Program Memory.
1.  8051 Timers “count up,” incrementing the Timer’s respective “count register” each time there is a triggering clock pulse. 2  When the “count register”
Lecture 13: TI MSP430 Watchdog Timer and Real-Time Clock
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
ECE 371- Unit 11 Timers and Counters (“Stop Watches and Alarm Clocks”)
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
System Clocks.
CS591 (Spring 2001) The Linux Kernel: Debugging. CS591 (Spring 2001) Accessing the “Black Box” n Kernel code: n Not always executed in context of a process.
M Semiconductor Products Sector Computer Operating Properly Module Detail Slide #1 of 7 Tutorial Introduction PURPOSE -To explain how to configure and.
Interrupts, Counter and Timers. Interrupts (1) Interrupt-driven I/O uses the processor’s interrupt system to “interrupt” normal program flow to allow.
MSP430 Mixed Signal Microcontroller – Parte 2 Afonso Ferreira Miguel Source: slau056d – Texas instruments.
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
ECE 353 Introduction to Microprocessor Systems Discussion 11.
Timers.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
ECE 371 – Unit 9 Interrupts (continued). Example Set up Two Interrupt Request Inputs: –Port H[0] Set Interrupt Flag on “0” to “1” transition (rising edge)
AVR Programming: Timers October 8, What is a timer? A register that keeps track of a current value This value is updated at a certain frequency.
Lab 5 – Digital Clock Start date: Week #8 Due date: Week #9 REPORT IS DUE WEEK #9 1.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Interrupts  An interrupt is any service request that causes the CPU to stop its current execution stream and to execute an instruction stream that services.
I NTRODUCTION TO PIC PROGRAMMING By : S HERIF H ARHASH.
Chapter 5 - Interrupts.
The Silicon Laboratories C8051F020
Computer Architecture Lecture 4 by Engineer A. Lecturer Aymen Hasan AlAwady 17/11/2013 University of Kufa - Informatics Center for Research and Rehabilitation.
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.
Razvan Bogdan Embedded Systems
1 Run-to-Completion Non-Preemptive Scheduler. 2 In These Notes... What is Scheduling? What is non-preemptive scheduling? Examples Run to completion (cooperative)
1 68HC11 Timer. 2 68HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output compare.
Timer & Watch Dog Test UNIT 16 로봇 SW 교육원 조용수. 학습 목표 Timer Init Timer Delay Test Timer Interrupt Test –One Shot Mode –Periodic Mode Watch Dog Test 시계 만들어.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
ELE22MIC Lecture 17 Writing 68HC11 software 68HC11 Main Timer System –Output Compare –What is different about TOC1?
Microprocessors A practical approach..
HCS12 Exceptions Maskable Interrupts
Example 14 Real-time Interrupts
68HC11 Interrupts & Resets.
Networked Embedded Systems Sachin Katti
Timer and Interrupts.
UNIT 5 TIMRERS/COUNTERS
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
전자의료시스템 및 실습 System Configuration/Interrupt
ECE 3430 – Intro to Microcomputer Systems
Resets & Interrupts.
EECE.3170 Microprocessor Systems Design I
Interrupt-Driven State Machine
Example 18 Pulse Train Using Interrupts
EECE.3170 Microprocessor Systems Design I
Wireless Embedded Systems
Programmable Interval Timer
ECE 3567 Microcontrollers Lab
Presentation transcript:

Real Time Interrupts Section 4.15

Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts are often counted to determine time and date (XP, LINUX) OS use RTI interrupts for process scheduling IBM PC is interrupted 18.2 times per second by RTI

Real-Time Interrupt Two Bits of Interest –RTIE – Real-Time Interrupt Enable “0” – Disables Interrupts “1” – Enables Interrupts –RTIF – Real-Time Interrupt Flag Set every T Seconds when RTIE=“1” Generates Maskable Interrupt when “1” Write “1” to RTIF to Clear Flag

Real Time Interrupt 68HC12DP256 Set Up and Controlled using 3 Registers: –RTICTL –CRGINT –CRGFLG

Clock Generator Lab Processor Boards uses a 4 MHz Crystal Oscillator Frequency of Bus Clock (ECLK) – 2 MHZ RTI uses the 4 MHZ Crystal Clock

4 MHZ SETS RTI FLAG Prescaler: Divides by 1, 2, 4, 8, 16, 32, or 64 Divides by 1, 2, 3, 4, 5, 6,, 16

Divide 4 MHZ Clock by: 1024 AND BY 1 or 2 or 4 or 8 or 16 or 32 or 64 (Selected by RTR[6:4]) AND BY 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10 or 11 or 12 or 13 or 14 or 15 or 16 (Selected by RTR[3:0]) to generate rate of RTI Timeout Output.

Real Time Interrupt Enable

Real Time Interrupt Flag Power-On Reset Flag Self-check Mode Interrupt Flag

Real Time Control Register

/* rtc1 = RTR[6:4], rtc = RTR[3:3] frti = Frequency of RTI */ int rtc1, rtc2; float frti; rtc1 = (RTR>>4)&0x07; rtc2 = RTR&0x0F; if(rtc1==0) frti=0; else frti = /(1024*(1<<(rtc1-1))*(rtc2+1)) Frequency of RTI

Init prescale factor in RTICTL Enable RTIE in CRGINT Reset RTIF in CRGFLG Enable maskable interrupts ENABLE(); CRGFLG

Text RTI Example RTI Interrupt every msec. E Clock is 4 MHZ RTICTL is defined differently Divide E Clock by 2 raised to power 15 –RTR[6:4] = 6 –RTR[3:0] = 0 –RTICTL = 0x60 RTI Interrupt Vector Address = 0xFFF0

TEXT RTI Examples Replace #include with #include Replace interrupt #pragma code with –void RTI_isr() __attribute__ ((interrupt)); Replace init vector #pragma code but place inside of main program Initialize Interrupt Vectors with –SETVECT(0xFFF0,RTI_isr);

Text RTI Example Replace RITCTL=0x84 with Set Interrupt Frequency, enable RTI, clear RTI –RTICTL = 0x60; –CRGFLG=0x80; –CRGINT = CRGINT | 0x80; Replace RTIFLG=0x80 with Clear RTI Flag –CRGFLG = 0x80; Replace CLI() Enable Interrupts with –ENABLE();

/* Real Time Interrupt Example Program Page of Text Modified to Execute on Lab Microcontroller This program keeps track of clock time using the Real Time Interrupts. The RTI generates an interrupt ms. The RTI_isr keeps track of elapsed time. */ /* include files */ #include /* function prototypes */ void RTI_isr(void) __attributes__ ((interrupt)); /* global variables */ unsigned int ms_ctr, sec_ctr, mins_ctr, hrs_ctr, days_ctr;

void main(void){ ms_ctr = 0; // initialize timer variables sec_ctr = 0; mins_ctr = 0; hrs_ctr = 0; days_ctr = 0; /* initialize RTI - - replaces pragma abs_address, etc. */ SETVECT(0xFFF0,RTI_isr); // interrupt vector // Replace RTICTL = 0x84; RTICTL = 0x60; // set interrupt frequency CRGFLG=0x80; // clear RTI interrupt flag CRGINT = CRGINT | 0x80; // enable RTI /* Enable Interrupts – replace CLI() */ ENABLE(); while(1); // wait for interrupts }

/* RTI_isr: RTI Interrupt Service Routine */ void RTI_isr(void) { // replaces RTIFLG CRGFLG = CRGFLG | 0x80; /* update milliseconds */ ms_ctr = ms_ctr+1; /* update seconds */ if(ms_ctr == 122) /* counter equates 1000 ms at 122 */ { ma_ctr = 0; // reset millisecond counter sec_ctr = sec_ctr +1; // increment seconds counter

/* update minutes */ if(sec_ctr == 60) { sec_ctr = 0; // reset seconds counter mins_ctr = mins_ctr+1; // increments minutes counter } /* update hours */ if(mins_ctr == 60) { mins_ctr = 0; // reset minutes counter hrs_ctr = hrs_ctr + 1 // increments hours counter } /* update days */ if(hrs_ctr == 24) { hrs_ctr = 0; // reset hours counter days_ctr = days_ctr + 1; // increment days counter }