Example 15 Interrupt-Driven Controller

Slides:



Advertisements
Similar presentations
C Examples 1.
Advertisements

Example 11 Analog-to-Digital Converter Lecture L5.1.
C Language Programming. C has gradually replaced assembly language in many embedded applications. Data types –C has five basic data types: void, char,
AVR Programming CS-212 Dick Steflik. ATmega328P I/O for our labs To get data into and out of our Arduino its a little trickier than using printf and.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
1 4-Integrating Peripherals in Embedded Systems (cont.)
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
KyungHee Univ. 2-0 Parallel Port LED Interfaces. KyungHee Univ. 2-1 Output LEDs.
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
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.
The miniDragon+ Board and CodeWarrior Lecture L2.1.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Arch1 LCD Lab Eric Freudenthal. Topics Score Demo LCD Panel Geometry Utilities to draw to the display Drawing characters Buttons Nuisance: multiple versions.
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)
Serial Communication Interface Ta Kim Nicholas Earnhart Razid Ahmad ME 6405 – Fall 2008 November 6, 2008.
displayCtrlr Specification
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Example 11 Analog-to-Digital Converter Lecture L5.1.
Example 12 Pulse-Width Modulation (PWM): Motors and Servos Lecture L8.1.
Warmup – 16FEB2012 This one is for practice. I have paper if you need it. Suppose there are eight, single-pole, single-throw (SPST) switches connected.
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
Real Time Interrupts Section Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts.
C Examples 1. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
C Examples 1. Download Links dsPIC30F4011/4012 Data Sheet dsPIC30F4013/3014 dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
UNIT 7 - INTRODUCTION TO I/O INTERFACING. TWO MAJOR TYPES OF I/O INTERFACING ISOLATED I/O - DEDICATED I/O INSTRUCTIONS ARE USED TO ACCESS I/O DEVICES.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
Examples Lecture L2.2. // Example 1a: Turn on every other segment on 7-seg display #include /* common defines and macros */ #include /* derivative.
Microcontrollers JULES CALELLA. Microcontrollers vs Microprocessors  Microprocessors – do not contain RAM, ROM, I/O  Microcontrollers – The whole package.
Atmega328p Introduction for Digital and PWM Output Brion L Fuller II Robotics Club.
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
LCD Interfacing using Atmega 32
80C51 Block Diagram ECE Overview.
Embedded Systems Programming Examples and Comparison
Morse code lab Pseudo code: Start code; define variables
4-Integrating Peripherals in Embedded Systems (cont.)
Example 14 Real-time Interrupts
Microcontroller 8951S #interface-2.
Microprocessor Systems Design I
Microprocessor Systems Design I
4-Integrating Peripherals in Embedded Systems
Example 19 Measuring Pulse Widths Using Interrupts
4-Integrating Peripherals in Embedded Systems
Arduino.
EECE.3170 Microprocessor Systems Design I
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.
The Arduino Microcontroller: Atmel AVR Atmega 328
8051 Programming in C rhussin.
Example 10 ASCII String to Binary Conversion
Example 5 Pushbutton Switches: S1 and S2
Objective of the lesson
IoT Programming the Particle Photon.
Example 9 Binary to ASCII String Conversion
Example 6 Hex Keypad Lecture L3.2.
using the Arduino to make LEDs flash
Interrupts in C Programs
Example 16 Circular Queue
Example 13 The Serial Peripheral Interface (SPI)
Example 17 SCI Receive Interrupts
Example 7 Liquid Crystal Display
EE 319K Introduction to Embedded Systems
EECE.3170 Microprocessor Systems Design I
EE 319K Introduction to Embedded Systems
Interrupt-Driven State Machine
8051 Micro Controller.
Example 18 Pulse Train Using Interrupts
EECE.3170 Microprocessor Systems Design I
PIC16F887.  1.Microcontroller introducton  2.MPLAB,Hi-tech compilers  3.LED  4.Switches/push buttons  5.7-Segment Display  6.Keypad  7.LCD  8.Timers.
Presentation transcript:

Example 15 Interrupt-Driven Controller Lecture L6.2

Connecting an LED to a Port P pin

// Example 15a Traffic Lights #include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" int dtime; // delay time int ix; // index into states const int numstates = 6; const char PortH[] = { // --RYGRYG 0x0C, // 00001100 0x14, // 00010100 0x24, // 00100100 0x21, // 00100001 0x22, // 00100010 0x24, // 00100100 }; const int delay[] = { 488, // 5 sec delay 98, // 1 sec delay 98, // 1 sec delay 488, // 5 sec delay

void interrupt 7 handler(){ dtime--; if(dtime == 0){ PTH = PortH[ix]; // turn on next lights dtime = delay[ix]; // get next delay time ix++; // increment index if(ix == numstates){ // after going through all states ix = 0; // reset index to 0 } clear_RTI_flag();

void main(void) { PLL_init(); // set system clock frequency to 24 MHz DDRH = 0xFF; // all bits of Port H are outputs RTI_init(); // initialize RTI to 10.24 ms interrupts ix = 0; // reset index into states dtime = 1; // start traffic light right away while(1) { // do nothing while traffic light goes }

Interrupt-Driven Blinking SOS International Morse Code

// Example 15b: Interrupt-Driven Controller: SOS #include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" unsigned short dtime; // delay time int ix; // index into states const int numstates = 18; const char seg7[] = { 0x6D, 0x00, 0x6D, 0x00, 0x6D, 0x00, // S 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, // O }; const char delay[] = { 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, // dots 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, // dashes 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x30, // dots

void interrupt 7 handler(){ dtime--; if(dtime == 0){ seg7_on(seg7[ix]); // turn on next display dtime = delay[ix]; // get next delay time ix++; // increment index if(ix == numstates){ // after going through all states ix = 0; // reset index to 0 } clear_RTI_flag();

void main(void) { PLL_init(); // set system clock frequency to 24 MHz seg7_enable(); RTI_init(); ix = 0; // reset index into states dtime = 1; // start display right away while(1) { // do nothing while display goes }