Interrupt-Driven State Machine

Slides:



Advertisements
Similar presentations
10-1 EE 319K Introduction to Microcontrollers Lecture 10: Interrupts, Output Compare Periodic Interrupts Read Book Sections 9.1, 9.2, 9.4, 9.6.1, 9.6.2,
Advertisements

1 I/O and Interrupts Today: First Hour: I/O Concepts –Section of Huang’s Textbook –In-class Activity #1 Second Hour: Interrupt Code Example –In-class.
ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Assembler Programming Chapter 6. EEL-4746 Best Practices.
68HC11 Polling and Interrupts
Introduction to Interrupts
Parallel Ports Lecture L4.1. Parallel Interfacing Parallel I/O Ports Using Parallel Ports.
Programming the HC12 in C. Some Key Differences – Note that in C, the starting location of the program is defined when you compile the program, not in.
1-1 Ramesh Yerraballi EE 319K Introduction to Microcontrollers Lecture 1: Introduction, Embedded Sys, Product Life- Cycle, 9S12 Programming.
© 2010 Kettering University, All rights reserved..
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
CEG411/611 Microprocessor Based System Design What is this course about? Computer : Processor, Memory, I/O Microprocessor versus microcontroller Embedded.
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
Week #5 General Interfacing Techniques
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
ME 4447/6405 Interrupts and Resets Suzanne Price Scott Gilliliand Greg Graf.
ELE22MIC Lecture 15 Applications of Parallel Input Output (I/O)
6-1 EE 319K Introduction to Microcontrollers Lecture 6: Indexed Addressing Mode and Variants, Functional Debugging, Arrays, Strings.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.
1 Segments and Pseudo Operations Program Development.
Keypad Lecture L4.6. Port Integration Module PIM_9C32 Block Guide V01.06 Reference: S12C32PIMV1.pdf.
Assembly Language ELEC 330 Digital Systems Engineering Dr. Ron Hayne.
EE 345 Class Notes EE345 Midterm Review Dr. Jane Dong.
The Serial Communication Interface (SCI) MC9S12-C32
ECE Lecture 21 Typical Assembly Language Program Bugs.
Real Time Interrupts Section Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts.
Microcontroller Fundamentals & Programming Arithmetic Instructions.
ECE 447: Lecture 16 Common Errors & Good Programming Style.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Embedded Systems Lecture 5 January 25 th, 2016.
Interrupt-Driven I/O There are different types of interrupts –Hardware Generated by the 8259 PIC – signals the CPU to suspend execution of the current.
1 68HC11 Timer. 2 68HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output compare.
Physics 413 Chapter 5 Well-Connected Monitor is TV screen attached to your PC Monitor is software “burned” (stored) in ROM. It boots up your computer.
1 Subroutines Advanced Programming. 2 Top-Down approach to problem solving Algorithm step by step description of how to solve a problem Divide and Conquer.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
SCI Communication Proudly Presented By: Adam Cardi & Aaron Enes.
ELE22MIC Lecture 17 Writing 68HC11 software 68HC11 Main Timer System –Output Compare –What is different about TOC1?
ECE 447: Lecture 13 Assembler Directives. ECE 447: Defining a Constant #define PORTB 0x1004PORTB EQU $1004 #define DELAY 100 ………. #undef DELAY #define.
ELE22MIC Lecture 18 Writing 68HC11 software 68HC11 Main Timer System
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Example 14 Real-time Interrupts
Interfacing the HC(S)12 microcontroller to a Hitachi/Optrex LCD Display Panel The LCD display panel contains its own microcontroller (Hitachi HD44780)
ECE 3430 – Intro to Microcomputer Systems
Buffered, Interrupt-Driven Printer Design Example
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Learning Outcome #1 Architecture and Programming Model
HC11 Programming.
Control Structure Applications
ECE 3430 – Intro to Microcomputer Systems
ELE22MIC Lecture 18 Writing 68HC11 software 68HC11 Main Timer System
ECE 3430 – Intro to Microcomputer Systems
Buffered, Interrupt-Driven Printer Design Example
ECE 3430 – Intro to Microcomputer Systems
Interrupt Source: under
“Assembly Table Lookup”
ECET 330 Innovative Education--snaptutorial.com
Oct 25 Announcements HW 8 posted
Branching and Looping Lecture L3.2.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Example 15 Interrupt-Driven Controller
Branching and Loops.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ECE 447: Lecture 15 Stack Operations.
Indexing Through Memory
Decisions in assembler code
Accum A: Index X: CCR Bit Z: $0100 $0101 $0102 $0103 $0104 $0105
Presentation transcript:

Interrupt-Driven State Machine Lecture L4.2a

State Machine with Delay

Use Real-time Interrupt with 50 ms Period State LED Delay (sec) S0 Red 0.5 S1 Yellow 1.0 S2 Green 0.75

State Machine with Delay

Data Structure Variable Value Dtime 1 Num_states 3 Cur_state S0 $80 10 S1 $40 S1t 20 S2 $20 S2t 15

$7B

; LED state machine example ptp equ $258 ; Port P ddrp equ $25A ; Direction ptj equ $268 ; Port J ddrj equ $26A ; Direction rti_ivec equ $0FF2 crgflg equ $0037 crgint equ $0038 rtictl equ $003b Note: Should be $0FF0. Monitor error

ORG $800 dtime db 1 num_states db 3 cur_state db 3 s0 db $80 ;red led s0t db 10 ;1/2 sec delay s1 db $40 ;yellow led s1t db 20 ;1 sec delay s2 db $20 ;green led s2t db 15 ;3/4 sec delay

ORG $4000 main jsr portp_init jsr rti_init mn1 bra mn1 portp_init ldaa #$E0 ;PP7..PP5 outputs staa ddrp ldaa #0 staa ptp ;leds off rts rti_init sei ;disable interrupts ldaa #$7b staa rtictl ;set rti to 49.15 ms ldaa #$80 staa crgint ;enable r ldx #rti_intser stx rti_ivec ;store rti int vector cli ;enable interrupts

rti_intser ldaa dtime deca ;dec dtime bne exit ;if not zero ldab cur_state cmpb num_states ; if cur_state = num_state bne ri1 clrb stab cur_state ; reset cur_state to 0 ri1 lslb ; ptr = cur_state * 2 ldx #s0 ; x -> state 0 abx ; x -> next state ldaa 0,x ; get state value staa ptp ; and display it inc cur_state ; update cur_state ldaa 1,x ; get delay time exit staa dtime ; and store it in dtime ldaa #$80 staa crgflg ;clear rti flag rti

ORG $800 dtime db 1 num_states db 3 cur_state db 3 s0 db $80 ;red led s0t db 10 ;1/2 sec delay s1 db $40 ;yellow led s1t db 20 ;1 sec delay s2 db $20 ;green led s2t db 15 ;3/4 sec delay