Post Lab Quiz 3 Review Assignment 2 Help

Slides:



Advertisements
Similar presentations
Lab. 2 Overview. Lab. 2 and Assignment 3 Many Lab. 2 and Assignment 3 tasks involve “downloading” provided code, compiling and linking into a project.
Advertisements

A look at interrupts What are interrupts and why are they needed.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
The planned but unexpected Program Sequencer controls program flow and provides the next instruction to be executed Interrupt – causing and handling.
6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 1 Temperature Sensor Laboratory 2 Part 2 – Developing.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
Review of Blackfin Syntax Moves and Adds 1) What we already know and have to remember to apply 2) What we need to learn.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
HD44780 LCD programming From the Hardware Side Design and implementation details on the way to a valid SPI-LCD interface driver.
A look at interrupts What are interrupts and why are they needed in an embedded system? Equally as important – how are these ideas handled on the Blackfin.
Timers and Timing Signals Tutorial. 6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3.
A look at interrupts What are interrupts and why are they needed.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
HD44780 LCD programming From the Hardware Side
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM511.
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system Manual control of RC car.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Lab. 2 Overview. Echo Switches to LED Lab1 Task 7 12/4/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 2 / 28.
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.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
Embedded Programming and Robotics Lesson 11 Arduino Interrupts 1.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved,
Developing Tasks to use with a co-operative scheduler Ideas for Assignment 2 Lab. 2, 3 and 4 Review for Midterm on Lab. 2 Ideas of defects, errors and.
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
An Introduction to Embedded Systems, and the PIC Microcontroller Lecture 8: Interrupts The aims of this session are to explore the structure and application.
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
Interrupts In 8085 and 8086.
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
SPI Compatible Devices
Lab. 2 Overview.
A Play Core Timer Interrupts
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Thermal arm-wrestling
ENCM K Interrupts Theory and Practice
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Lab. 2 – More details – Later tasks
SPI Compatible Devices
CSC 253 Lecture 7.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Thermal arm-wrestling
Lab. 4 – Part 1 Demonstrating and understanding multi-processor boot
A Play Lab. 2 Task 8 Core Timer Interrupts
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
HD44780 LCD programming From the Hardware Side
HD44780 LCD programming From the Hardware Side
Thermal arm-wrestling
Blackfin Timers Independent timers build into the Blackfin
Lab. 4 – Part 2 Demonstrating and understanding multi-processor boot
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Independent timers build into the processor Basis for Lab. 2
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Blackfin Timers Independent timers build into the processor
Independent timers build into the processor
Developing a bicycle speed-o-meter
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system.
Developing a bicycle speed-o-meter
Thermal arm-wrestling
Developing a reliable communication between Blackfin and Slave device
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Blackfin Syntax Moves and Adds
Presentation transcript:

Post Lab Quiz 3 Review Assignment 2 Help Interrupts

Mixture of Q2 and Q4 on Midterm Using PF interrupts on a Blackfin Count the number of times a door is opened On the press of a button, print out the information 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada What do we need to know? How are switches hooked to Blackfin? How to handle 2 interrupt ISRs? How to acknowledge the hardware ISR request How to test the ISR How to make ISR fast (no printf permitted)? How do we initialize Blackfin PF interrupts? How do we start the interrupts controllably 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Do easy stuff first Need to do just one print when master switch is pressed Connect to PF8 input. Works like in Lab 1 -- switch press causes PF8 input to go high NOTE: I DID NOT say – switch press causes PF8 bit to go high – I said the input went high 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Do easy stuff first Need to increment count by when door opened Connect to PF9 input. Works like in Lab 1 – door opencauses PF9 input to go low NOTE: I DID NOT say – switch press causes PF9 bit to go low – I said the input went low 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Plan the main Main( ) InitPF( ) – like Lab 1 – given InitPFInterrupts( ) – uses Lab 1 ideas but turns on stuff normally turned off OtherCode( ) StartPFInterrupts( ) while (1) // If master switch pressed – print once 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Plan the ISR Ex_Interrupt_Handler(PF_Interrupts) // Only gets here on PF interrupts if PF8 interrupt Acknowledge PF8 interrupt DoSomething_PF8 if PF9 interrupt Acknowledge PF9 interrupt DoSomething_PF9 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Try again -- main and ISR communicate by globals volatile int PF9interrupt_doPrint = 0; volatile int PF8interrupt_countDoorOpens = 0; main( ) InitPF( ) – like Lab 1 – given InitPFInterrupts( ) – uses Lab 1 ideas but turns on stuff normally turned off OtherCode( ) StartPFInterrupts( ) while (1) { if PF9interrupt_doPrint != 0 { printf(PF8interrupt_countDoorOpens); PF9interrupt_doPrint = 0; PF8interrupt_countDoorOpens = 0; } 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Plan the ISR extern volatile int PF9interrupt_doPrint; extern volatile int PF8interrupt_countDoorOpens; Ex_Interrupt_Handler(PF_Interrupts) // Only gets here on PF interrupts caused by edges if PF8 interrupt Acknowledge PF8 interrupt PF8interrupt_countDoorOpens++ if PF9 interrupt Acknowledge PF9 interrupt PF9interrupt_doPrint = 1; 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada ISR rules If PF8 input goes from lo-to-high PF set using InitPF from Lab 1 And edge register set to PF8 edge And polar register set to PF8 normal And mask-A register set to PF8 And IMASK is set correctly And SIC_IMASK is set correctly Then PF8 is set to 1 and interrupt occurs 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada ISR rules If PF9 input goes from high-to-low PF set using InitPF from Lab 1 And edge register set to PF9 edge And polar register set to PF9 opposite to normal And mask-A register set to PF9 And IMASK is set correctly And SIC_IMASK is set correctly Then PF9 is set to 1 and interrupt occurs NOTE PF9 input goes low by PF9 goes high 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

ISR rules – specific to PF interrupts It is possible for two interrupts to happens at once You clear the PF8 interrupt by clearing the PF8 bit to zero It will stay zero even if the PF8 level input stays high (because you said ‘edge’ interrupts and not level) You clear the PF9 interrupt by clearing the PF9 bit to zero It will stay zero even if the PF9 level input stays low (because you said ‘edge’ interrupts and not level) 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Plan the ISR extern volatile int PF9interrupt_doPrint; extern volatile int PF8interrupt_countDoorOpens; Ex_Interrupt_Handler(PF_Interrupts) // Only gets here on PF interrupts caused by edges int flags = *pFIO_FLAG_D if (Flags & 0x0100) { *pFIO_FLAG_D = *pFIO_FLAG_D & ~0x0100 // Acknowledge PF8 interrupt PF8interrupt_countDoorOpens++ } if PF9 interrupt -- you handle it Acknowledge PF9 interrupt PF9interrupt_doPrint = 1; 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada InitPFInterrupts( ) Assume PF8, PF9 set as enable, polar = 0, interrupts off, direction input – like Lab 1 *pFLAGS_MASKA // Prepare PF interrupts = *pFLAGS_MASKA | (0x0100 | 0x0200) *pFLAGS_EDGE // Prepare PF interrupts = *pFLAGS_EDGE | (0x0100 | 0x0200) // PF9 is on ‘down edge’ – use POLAR *pFLAGS_POLAR // Prepare PF interrupts = *pFLAGS_POLAR | (0x0200) 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

ActivateInterrupts( ) This is not in the labs, only in the lecture notes 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Follow the chain If PF set up correctly (DONE) Then Interrupt A occurs on switch presses automatically – already If SIC_IMASK is set (???) And Priority set (SIC_IAR0) (???) Then ILAT is set automatically then is IMASK is set (???) And event vector table is set (???) Then an PF interrupt will occur 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Time to look at reference sheet So we need *pSIC_IMASK = *pSIC_IMASK | 0x00080000 PF Interrupt 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Problems – need to know about an IV???? to handle the next bit? 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada InterruptActivate( ) *pSIC_IMASK = *pSIC_IMASK | 0x00080000; ssync( ); // PF Interrupt *pIMASK = *pIMASK | 0x00001000; Ssync( ); // IVG_12 register_handler(k_IVG12, PF_Interrupts); 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Planning over – lets doit Use VDSP help to find out what files need including for interrupt handling Why does the help page have 2 defects #include <sys/exception.h> static int number_of_interrupts;    EX_INTERRUPT_HANDLER(my_isr) {    number_of_interrupts++; } 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada 5/14/2019 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada