Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| learn:courses:unit-2:start [2017/06/08 17:23] – [Listing A.3. Example Timer Delay Using Interrupt Flag Polling] brandon marcum | learn:courses:unit-2:start [2022/10/04 04:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| [[{}/ | [[{}/ | ||
| ==Unit 2 Labs== | ==Unit 2 Labs== | ||
| - | * [[https:// | + | * [[/ |
| - | * [[https:// | + | * [[/ |
| Line 36: | Line 36: | ||
| ===== 4. Unit Equipment List ===== | ===== 4. Unit Equipment List ===== | ||
| ==== 4.1. Hardware ==== | ==== 4.1. Hardware ==== | ||
| - | - [[http://store.digilentinc.com/ | + | - [[https://digilent.com/shop/ |
| - | - [[http://store.digilentinc.com/ | + | - [[https://digilent.com/shop/ |
| - Workstation computer running Windows 10 or higher, MAC OS, or Linux | - Workstation computer running Windows 10 or higher, MAC OS, or Linux | ||
| - | - [[http://store.digilentinc.com/ | + | - [[https://digilent.com/shop/ |
| - | - [[http://store.digilentinc.com/5v-4000ma-switching-power-supply/ | + | - [[https://digilent.com/shop/5v-4a-switching-power-supply/ |
| ==== 4.2. Software ==== | ==== 4.2. Software ==== | ||
| Line 63: | Line 63: | ||
| The correct operation of a dynamic real-time scheduling scheme is predicated on two requirements. The first is that the worst case (longest) execution time of the timer interrupt service routine (ISR) must be less than the interrupt interval. The second is that the time remaining in the interrupt period after execution of the ISR must be sufficient so that it appears to the user that the processor is acknowledging his or her inputs in a timely manner. | The correct operation of a dynamic real-time scheduling scheme is predicated on two requirements. The first is that the worst case (longest) execution time of the timer interrupt service routine (ISR) must be less than the interrupt interval. The second is that the time remaining in the interrupt period after execution of the ISR must be sufficient so that it appears to the user that the processor is acknowledging his or her inputs in a timely manner. | ||
| - | Real-time operation has two basic requirements: | + | Real-time operation has two basic requirements: |
| The time required to service the ISR includes the execution time of the user ISR code in addition to the time required to save and restore the system context. Using the MPLAB X Stopwatch debugging feature, we find that it requires 33 machine cycles to save and restore the system context. Using a core frequency of 80 MHz, the context saving and restoring time is 1.03 μs. The time to execute the user written code varies. In the case of Labs 2a and 2b, execution of the ISR code will vary based upon the conditional execution of the LED and stepper motor functions. | The time required to service the ISR includes the execution time of the user ISR code in addition to the time required to save and restore the system context. Using the MPLAB X Stopwatch debugging feature, we find that it requires 33 machine cycles to save and restore the system context. Using a core frequency of 80 MHz, the context saving and restoring time is 1.03 μs. The time to execute the user written code varies. In the case of Labs 2a and 2b, execution of the ISR code will vary based upon the conditional execution of the LED and stepper motor functions. | ||
| Line 251: | Line 251: | ||
| ==== Listing 7.6. Timer 1 ISR at Interrupt Level 2 ==== | ==== Listing 7.6. Timer 1 ISR at Interrupt Level 2 ==== | ||
| < | < | ||
| - | void __ISR(_TIMER_1_VECTOR, | + | void __ISR(_TIMER_1_VECTOR, |
| { | { | ||
| Line 440: | Line 440: | ||
| The maximum counter value is determined by the size of the register that holds the counts. Common sizes for microprocessors are 8-, 16-, and 32-bit. Including the core timer, the PIC32 processor has six timers that can be used for delay timing. The core timer is 32 bits wide. Timers 2 and 3 along with Timers 4 and 5 can be used together as 32-bit counters, respectively, | The maximum counter value is determined by the size of the register that holds the counts. Common sizes for microprocessors are 8-, 16-, and 32-bit. Including the core timer, the PIC32 processor has six timers that can be used for delay timing. The core timer is 32 bits wide. Timers 2 and 3 along with Timers 4 and 5 can be used together as 32-bit counters, respectively, | ||
| - | The period register is used to set the timer’s maximum count. If a period equal to a value of N is set, then N-1 is written to the PR register. The period registers are declared as PR1 for Timer 1, PR2 for Timer 2, and so on. Each Timer 1 count is compared to the value of the PR1 register. When the PR1 register equals the Timer 1 register, the timer has reached its terminal count and initiates two actions: first, the Timer 1 register is reset to zero, and second, the Timer 1 Interrupt Flag (T1IF) bit is set in the Interrupt Flag Status register (IFS0). (See the [[http:// | + | The period register is used to set the timer’s maximum count. If a period equal to a value of N is set, then N-1 is written to the PR register. The period registers are declared as PR1 for Timer 1, PR2 for Timer 2, and so on. Each Timer 1 count is compared to the value of the PR1 register. When the PR1 register equals the Timer 1 register, the timer has reached its terminal count and initiates two actions: first, the Timer 1 register is reset to zero, and second, the Timer 1 Interrupt Flag (T1IF) bit is set in the Interrupt Flag Status register (IFS0). (See the [[http:// |
| As Fig. A.3 illustrates, | As Fig. A.3 illustrates, | ||
| Line 564: | Line 564: | ||
| / | / | ||
| * The purpose of this example code is to demonstrate the use of the Type A | * The purpose of this example code is to demonstrate the use of the Type A | ||
| - | * Timer 1 interrupts to generate a 1 ms delay. | + | * Timer 1 interrupts to generate a 1 second |
| * | * | ||
| * Platform: | * Platform: | ||
| Line 585: | Line 585: | ||
| ********************************************************************/ | ********************************************************************/ | ||
| - | #include < | + | #include < |
| #include " | #include " | ||
| - | #include " | + | #include " |
| /* Application constant */ | /* Application constant */ | ||
| - | #define T1_PRESCALE | + | #define T1_PRESCALE |
| - | #define TOGGLES_PER_SEC | + | #define TOGGLES_PER_SEC |
| #define T1_TICK | #define T1_TICK | ||
| Line 627: | Line 627: | ||
| * SYNTAX: | * SYNTAX: | ||
| * KEYWORDS: | * KEYWORDS: | ||
| - | * DESCRIPTION: | + | * DESCRIPTION: |
| * Parameters: | * Parameters: | ||
| * RETURN: | * RETURN: | ||

