Display Interrupt Service Routine for cargo monitoring system

Slides:



Advertisements
Similar presentations
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Advertisements

Help for Assignment 2. Topics Tackled Handling some “C++” keywords when programming assembly code –Programming “subroutines called by subroutines” –Programming.
Assignment Overview Thermal oscillator One of the ENCM415 Laboratory 2 items Oscillator out GND +5V.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
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.
Calculating acceleration using ADXL213 – dual axis accelerometer.
Display Interrupt Service Routine for cargo monitoring system Overview of concepts demonstrated during Labs 3 and 4.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
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.
Lab. 2 Overview 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have that knowledge?
Timers and Timing Signals Tutorial. 6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3.
Development of cargo monitoring system for a rapid response team (disaster aid) Overview of concepts that you will demonstrate during Labs 3 and 4.
Development of cargo monitoring system for a rapid response team (disaster aid) Overview of concepts demonstrated during Labs 3 and 4.
Getting the O in I/O to work on a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
Later tasks of Lab. 1 For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
Peripherals and their Control An overview of industrially available “peripheral devices” that use “pulse-width modulation” for information passing. Review.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
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.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
Calculating acceleration using ADXL213 – dual axis accelerometer Use equivalent idea in Lab. 3 with thermal sensor.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Embedded Programming and Robotics Lesson 11 Arduino Interrupts 1.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
Assignment 4 / Lab. 3 Convert C++ ISR to ASM AND GET IT TO WORK Doing Assignment 4 / Lab. 3 the Test Driven Development way.
“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.
INTRODUCTION TO ROBOTICS Part 5: Programming
Concurrency.
Help for Lab. 1 Subroutines calling Subroutines
Software Development with uMPS
Arithmetic using a stack
Lab. 2 Overview – Earlier Tasks Prelaboratory T1, T3, T4 and T5
Software and Hardware Circular Buffer Operations
Generating the “Rectify” code (C++ and assembly code)
Conditionals & Boolean Expressions
A Play Core Timer Interrupts
Thermal arm-wrestling
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Coding Concepts (Sub- Programs)
TigerSHARC processor and evaluation board
Lab. 2 – More details – Later tasks
Thermal arm-wrestling
Faculty of Computer Science & Information System
A Play Lab. 2 Task 8 Core Timer Interrupts
General purpose timers
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
General purpose timers
Getting serious about “going fast” on the TigerSHARC
Thermal arm-wrestling
Explaining issues with DCremoval( )
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.
Independent timers build into the processor
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system.
Thermal arm-wrestling
Handling multiple input signals
slides created by Ethan Apter
Lecture 3 - Instruction Set - Al
Presentation transcript:

Display Interrupt Service Routine for cargo monitoring system Overview of concepts demonstrated during Labs 3 and 4

Cargo Monitoring System During transport Quick indication of health of product NOW Acceleration in range – accuracy of +- 1 / 8 G Temperature steady – accuracy of +- 1 / 32 C On delivery Display of ranges that cargo has experienced Range of temperatures and accelerations Other cargo information

Overall design General Purpose Timer controlling Display as ISR Temperature / Acceleration graphic (non-text) display Changes, actual temperatures main( ) Initialize stuff (C++) Calculate Temperature Core temperature ISR clock used for Temperature / Acceleration determination Store temperature, calculate averages and ranges Communications with LCD MOSI / MISO format -- ISR Temperature / Acceleration information Text format Calculate Acceleration Store acceleration, calculate averages and ranges

Develop first test -- Requirements variable acceleration_changing is modified in main( ) depending on whether current acceleration is greater than, equal to, or less than the average acceleration Display ISR uses this information to modify how the LED flash (flicker up, flicker down, steady) Set_Acceleration_Mode( current_Acc, average_ACC)

DisplayISR( ) Development This routine will be responsible for displaying both temperature and acceleration values You develop the necessary ISR for handling the Temperature display in Lab. 3 I’ll discuss the code for handling the Acceleration display in the lectures

Test that can call an ISR and return from the interrupt without crashing system Most of the notes from last Monday’s lecture on the general purpose timer interrupt service routine cover the topics here Need to test using “Software interrupt” generation using the “raise( )” C++ code Display under the control of interrupts from the general purpose timer 0

Test that can access and return from ISR #include <sys\exception.h> #include <cdefBF533.h> #include <ccblkfn.h> #include <sysreg.h> #include <signal.h> EX_INTERRUPT_HANDLER(Display_ISR_CPP); TEST(LinkToDisplayISR, SMITH_TEST) { register_handler(ik_ivg11, Display_ISR_CPP); CHECK(true); register_handler(ik_ivg11, Display_ISR_ASM); CHECK(true); register_handler(ik_ivg11, EX_INT_IGNORE); }

Recap - Minimum interrupt C++ stub for timer 0 EX_INTERRUPT_HANDLER(Display_ISR_CPP) { *pTIMER_STATUS |= 1; // Clear TIMIL0 (WIC) // See page 15 – 8 } Make sure you understand why this particular bit needs clearing in the timer status register and what would happen if were using general purpose TIMER1 or TIMER2 instead of TIMER0!

Recap - Assembly language version Minimum interrupt stub for timer 0 . section program; .global _Display_ISR_ASM__FiN21; // Question – why ISR name mangle __FiN21 _Display_ISR_ASM__FiN21: // when we can’t pass it any parameters? [--SP] = ASTAT; [--SP] = FP; [--SP] = (R7:0, P5:0); // Gross over-kill LINK 16; // Needs to refactored for speed P0.L = lo(TIMER_STATUS); // Clear the status bit TIMIL0 (W1C) p15-8 P0.H = hi(TIMER_STATUS); R0 = 1; W[P0] = R0; UNLINK; (R7:0, P5:0) = [SP++]; FP = [SP++]; ASTAT = [SP++]; _Display_ISR_ASM__FiN21.END: RTI;

Display Average Acceleration -- part of the GPT ISR Use WriteLEDASM( ) to display whether the average acceleration (calculated in main( )) is increasing, decreasing or staying the same Sort of “acceleration dancing lights” If staying the same – flash all lights on and off If increasing – race the lights to the left (0x00, 0x01, 0x02, 0x04, 0x08 etc) If decreasing – race the lights to the right (0x00, 0x20, 0x10, 0x08 etc) Basically more practice with left and right shift

Design details added main( ) #define ACCELERATION_STEADY 1 #define ACCELERATION_DECREASING 2 #define ACCELERATION_INCREASING 3 variable acceleration_changing Initialize stuff (C++) Calculate Temperature Communication between main( ) and ISR Store temperature, calculate averages and ranges General Purpose Timer controlling Display as ISR Temperature / Acceleration graphic (non-text) display Changes, actual temperatures Calculate Acceleration Store acceleration, calculate averages and ranges

Display Average Acceleration -- part of the GPT ISR Use WriteLEDASM( ) to display whether the average acceleration (calculated in main( )) is increasing, decreasing or staying the same Sort of “acceleration dancing lights” If staying the same – flash all lights on and off

Again write the Test Then write the code to satisfy the test TEST(StableAcceleration_ISR_CPP, DEVELOPER_TEST) { InitializeLEDInterfaceASM( ); ResetDisplay( ); register_handler(ik_ivg11, Display_ISR_CPP); acceleration_changing = 0; raise(SIGIVG11); // SWI – SoftWare Interrupt long int display_value = ReadLEDASM( ); CHECK(display_value == 0x00); // All lights off raise(SIGIVG11); display_value = ReadLEDASM( ); CHECK( display_value == 0x3F); // All lights on register_handler(ik_ivg11, EX_INT_IGNORE); }

ResetDisplay( ); Why is this function call here? No idea at the moment But sounds like a good idea to be able to do this. If we are going to run a series of tests and then check the display output, we will probably want to put the display into a known mode If not needed – then we will REFACTOR this function out of the code and the project. Calling a “do-nothing” routine does not hurt at this stage in project development

Write the tests for 20 SWI activations and display checking -- Max 10 lines of code TEST(MultipleTests_StableAcceleration_ISR_CPP, DEVELOPER_TEST) { }

Now write the code to satisfy the test EX_INTERRUPT_HANDLER(Display_ISR_CPP) { *pTIMER_STATUS |= 1; // Clear TIMIL0 (WIC) // See page 15 – 8 DisplayAverageAcceleration( ); // This is a subroutine // called from inside // an ISR // Perhaps later // DisplayAverageTemperature( ); // This is a subroutine // called from inside // an ISR }

Now write the code to satisfy the test // This is a subroutine called from inside an ISR // LATER will need to REFACTOR for speed, removing // all unnecessary code volatile long int acceleration_changing = 0; void DisplayAverageAcceleration(void) { static long int LEDdisplay_output = 0; if (acceleration_changing == 0) { LEDdisplay_output = 0x3F – LEDdisplay_output; WriteLEDASM(LEDdisplay_output); } }

Display Average Acceleration -- part of the GPT ISR Use WriteLEDASM( ) to display whether the average acceleration (calculated in main( )) is increasing, decreasing or staying the same Sort of “acceleration dancing lights” If increasing acceleration – race the lights to the left (0x00, 0x01, 0x02, 0x04, 0x08 etc)

Again write the Test Then write the code to satisfy the test TEST(IncreasingAcceleration_ISR_CPP, DEVELOPER_TEST) { InitializeLEDInterfaceASM( ); ResetDisplay( ); register_handler(ik_ivg11, Display_ISR_CPP); acceleration_changing = 1; raise(SIGIVG11); // SWI – SoftWare Interrupt long int display_value = ReadLEDASM( ); CHECK(display_value == 0x00); // All lights off raise(SIGIVG11); display_value = ReadLEDASM( ); CHECK( display_value == 0x01); // First light on register_handler(ik_ivg11, EX_INT_IGNORE); }

Write the tests for 20 SWI activations and display checking -- Max 10 lines of code TEST(MultipleTests_IncreasingAcceleration_ISR_CPP, DEVELOPER_TEST) { }

Now write the code to satisfy the test

Write the tests for decreasing acceleration, then write the code

Cargo Monitoring System -- update During transport Quick indication of health of product NOW Acceleration in range – accuracy of +- 1/8 G Temperature steady – accuracy of +- 1 / 32 C If average acceleration staying the same – flash all lights on and off If average acceleration increasing – race the lights to the left (0x00, 0x01, 0x02, 0x04, 0x08 etc) If average acceleration decreasing – race the lights to the right (0x00, 0x20, 0x10, 0x08 etc) Need a mechanism to able to display “current acceleration” as a value or display “average acceleration” Perhaps the switching will be caused by pressing SW3 on front panel

Must go back and modify the test TEST(StableAcceleration_ISR_CPP, DEVELOPER_TEST) { InitializeLEDInterfaceASM( ); ResetDisplay( ); register_handler(ik_ivg11, Display_ISR_CPP); acceleration_changing = 0; display_true_acceleration = false; raise(SIGIVG11); // SWI – SoftWare Interrupt long int display_value = ReadLEDASM( ); CHECK(display_value == 0x00); // All lights off raise(SIGIVG11); display_value = ReadLEDASM( ); CHECK( display_value == 0x3F); // All lights on register_handler(ik_ivg11, EX_INT_IGNORE); }

Must go back and modify the test for displaying the “average acceleration” TEST(StableAcceleration_ISR_CPP, DEVELOPER_TEST) { InitializeLEDInterfaceASM( ); ResetDisplay( ); register_handler(ik_ivg11, Display_ISR_CPP); display_true_acceleration = false; acceleration_changing = 0; raise(SIGIVG11); // SWI – SoftWare Interrupt long int display_value = ReadLEDASM( ); CHECK(display_value == 0x00); // All lights off raise(SIGIVG11); display_value = ReadLEDASM( ); CHECK( display_value == 0x3F); // All lights on register_handler(ik_ivg11, EX_INT_IGNORE); }

Now write the code to satisfy the test volatile bool display_true_acceleration = false; EX_INTERRUPT_HANDLER(Display_ISR_CPP) { *pTIMER_STATUS |= 1; // Clear TIMIL0 (WIC) // See page 15 – 8 if (display_true_acceleration == false) DisplayAverageAcceleration( ); // This is a subroutine // called from inside // an ISR // Perhaps later // DisplayAverageTemperature( ); // This is a subroutine // called from inside // an ISR }

Write a test for displaying acceleration Remember 1 g is stored as 0x10000 TEST(TemperatureDisplay_ISR_CPP, DEVELOPER_TEST) { InitializeLEDInterfaceASM( ); ResetDisplay( ); register_handler(ik_ivg11, Display_ISR_CPP); display_true_acceleration = true; acceleration = 0; raise(SIGIVG11); // SWI – SoftWare Interrupt long int display_value = ReadLEDASM( ); CHECK(display_value == 0x00); // All lights off acceleration = 1 * ACCELERATION_SCALE_FACTOR; raise(SIGIVG11); display_value = ReadLEDASM( ); CHECK( display_value == 0x10); // represent 0x1.0 g register_handler(ik_ivg11, EX_INT_IGNORE); }

Now write the code to satisfy the test volatile bool display_true_acceleration = false; EX_INTERRUPT_HANDLER(Display_ISR_CPP) { *pTIMER_STATUS |= 1; // Clear TIMIL0 (WIC) // See page 15 – 8 if (display_true_acceleration == true) // I prefer “positive tests” DisplayTrueAcceleration( ); // REFACTOR the code to match this else DisplayAverageAcceleration( ); // This is a subroutine // called from inside // an ISR // Perhaps later // DisplayAverageTemperature( ); // This is a subroutine // called from inside // an ISR }

Only thing left in Cargo Monitoring System to do is “measure the acceleration” During transport Quick indication of health of product NOW Acceleration in range – accuracy of +- 1 / 8 G Temperature steady – accuracy of +- 1 / 32 C On delivery Display of ranges that cargo has experienced Range of temperatures and accelerations Other cargo information