Individual Assignment 2 -- Defects, Interrupts and Errors

22 downloads 116 Views 205KB Size Report
Individual Assignment 2 -- Defects, Interrupts and Errors. Concepts around defects, errors and interrupts will be examined during Post Lab 3 Quiz scheduled on ...
Individual Assignment 2  ­­ Defects, Interrupts and Errors    Concepts around defects, errors and interrupts will be examined during Post Lab 3 Quiz scheduled on Friday December  3.  This assignment is due on Sunday 28th November, one week before the post‐lab 3 quiz – no extensions given.  As with  the previous assignment, students submitting the assignment early, Sunday 21st November, will receive a 10% bonus  on their assignment mark.  The requirements for the assignment are   • •

to develop, test and demonstrate the use of interrupts.  The student will demonstrate the use of the watch dog timer (Chapter 14 (Timer) and Chapter 4 (Sequencer) of  the hardware data manual) to either generate a general purpose interrupt (GPI)  or a reset interrupt . The choice  should be appropriate to the student’s demonstration code. Example code problems are given below.  • The student will need to develop and use the following routines – I would expect these routines to involve 2 to  20 lines of code. Use the information in the course notes and hardware manual  o void My_Init_WatchDogTimer(void);  o void My_Activate_WatchDogTimer(void);  o void My_Feed_WatchDogTimer(void);  o void My_DeActivate_WatchDogTimer(void);  o EX_INTERRUPT_HANDLER(MY_WatchDogISR); (first in C and then in assembly code);  o The C++ function – register_handler( )  • If SW1 IS NOT held down during the first part of the running of the program,  the interrupt service routine (ISR)  written in C++ is to be used.   • I f SW1 IS held down during the first part of the running of the program,  the interrupt service routine (ISR)  written in Blackfin assembly code is to be used.   • Once the code is working, you are to explore, and report on  the effect of the following errors / defects  o Using RTS to return from an interrupt rather than RTI – this is probably an ‘error’ as the code will run but  never work – meaning you can’t move onto the next phase of the project without fixing the problem in  this phase.  o Not saving one of the registers during the ISR – this is probably a ‘defect’ as whether it will cause a  problem will depend on when the interrupt ‘goes’ off and a race condition of whether the code is sitting  at ‘idle( )’ or inside a more complicated routine.  o Re‐compiling code with ‘release’ compiler mode and not using ‘volatile’ variables to communicate   between main code and ISR    The assignment mark is based on (A – 50%) the hand‐in of code after demonstrating the working code to somebody not  in ENCM51  (signature needed), and (B – 50%) demonstration of the code to a T.A. or myself during the lab period.           

 

PRACTICE – If you use the following code, you will be able to demonstrate the use of the watch‐dog in a TTCOS  environment.  This slide was discussed in class. You will need to have a task that “waits” for a long enough time to  trigger the watchdog   

    SUGGESTION 1 – Video game as demonstrated during class – except using your Watchdog routines routine.   Pseudo‐ code follows – ISR is controlling ‘quit’ – use reset mode of watch dog timer rather than NMI as shown in slide 

   

Suggestion 2 ‐‐  In Lab 1 and Lab 2 – we are using ‘press SW4 with command 0 – three times” to move between ‘record  the car commands’ to ‘play back the car commands’. Modify the operation of one of these task to make use of watchdog  ISR  Activate the watchdog  Have a task that polls whether the interrupt request has been made (use GPI request not reset) – when the  interrupt goes off move from the record mode top the play‐back mode  Suggestion 3 – Between pins PF11 and RST and between pins PF8 and PF7 there are two connectors labeled Timer 0 and  Timer 1. Activate these timers ‘measure pulse width and period’ mode (part of Lab 3). You can then hook up SW5 and  SW6 from the logic lab extender boards and actually beat the watchdog timer in the video game.  This is a more  interesting embedded system task, but more difficult than the other suggestions. You can always switch back to  suggestion 1 if things don’t work out!    Suggestion 4 – This assignment is all about using interrupts. Another alternative is to modify Lab 1 ReadGPIOFlags( ) to  ONLY read the GPIO flag SW4  when PF11 goes from low to high and causes an interrupt. This is a more interesting  embedded system task, but more difficult than the other suggestions. You can always switch back to suggestion 1 if  things don’t work out!    Suggestion 5 – Suggest your own interrupt task with me before the end of this week Nov 5, and do that for this  assignment.  This is a more interesting embedded system task, but more difficult than the other suggestions. You can  always switch back to suggestion 1 if things don’t work out!