Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
learn:microprocessor:tutorials:pic32-interrupts:start [2017/12/18 21:07] – Marthalearn:microprocessor:tutorials:pic32-interrupts:start [2022/10/04 11:38] (current) – external edit 127.0.0.1
Line 13: Line 13:
  
 ==== Inventory ==== ==== Inventory ====
-  * 1 [[http://store.digilentinc.com/digilent-pro-mx7-pic32-based-embedded-systems-trainer-board/| Digilent Pro MX7]]+  * 1 [[https://digilent.com/shop/digilent-pro-mx7-pic32-based-embedded-systems-trainer-board/| Digilent Pro MX7]]
   * [[http://www.microchip.com/mplab/mplab-x-ide| MPLAB X IDE]]   * [[http://www.microchip.com/mplab/mplab-x-ide| MPLAB X IDE]]
-  * 1 [[http://store.digilentinc.com/pmod-step-stepper-motor-driver/| Pmod STEP]]+  * 1 [[https://digilent.com/shop/pmod-step-stepper-motor-driver/| Pmod STEP]]
   * 1 Stepper Motor (5V – 12V, 25 Ω, unipolar or bi-polar)   * 1 Stepper Motor (5V – 12V, 25 Ω, unipolar or bi-polar)
-  * 1 Logic analyzer or oscilloscope (Digilent [[http://store.digilentinc.com/analog-discovery-100msps-usb-oscilloscope-logic-analyzer-limited-time/| Analog Discovery]] or [[http://store.digilentinc.com/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply/| Analog Discovery 2]] recommended)+  * 1 Logic analyzer or oscilloscope (Digilent [[https://digilent.com/reference/test-and-measurement/analog-discovery/start| Analog Discovery]] or [[https://digilent.com/shop/analog-discovery-2-100ms-s-usb-oscilloscope-logic-analyzer-and-variable-power-supply/| Analog Discovery 2]] recommended)
  
 ---- ----
Line 26: Line 26:
 \\ \\
 <html> <html>
-<a href="https://reference.digilentinc.com/learn/microprocessor/tutorials/pmod-step-parts-layout/start" class="btn btn-success" role="button">Pmod STEP Parts Layout</a>+<a href="/learn/microprocessor/tutorials/pmodstep-parts-layout/start" class="btn btn-success" role="button">Pmod STEP Parts Layout</a>
 </html> </html>
 \\ \\
 \\ \\
 <html> <html>
-<a href="https://reference.digilentinc.com/learn/microprocessor/tutorials/pic32-interrupts/start" class="btn btn-success" role="button">PIC32 Interrupts</a>+<a href="/learn/microprocessor/tutorials/pic32-interrupts-appendices/start" class="btn btn-success" role="button">PIC32 Interrupts</a>
 </html> </html>
 \\ \\
Line 114: Line 114:
  
 <html> <html>
-<a href="https://reference.digilentinc.com/learn/microprocessor/tutorials/pic32-interrupts/start" class="btn btn-success" role="button">PIC32 Interrupts</a>+<a href="/learn/microprocessor/tutorials/pic32-interrupts-appendices/start" class="btn btn-success" role="button">PIC32 Interrupts</a>
 </html> </html>
 \\ \\
Line 291: Line 291:
 Now that you've completed this project, you should look at the following questions/problems: Now that you've completed this project, you should look at the following questions/problems:
  
 +<html>
 +<ol type="1">
 +<li>Develop a DFD and a CFD for this project.</li>
 +</br>
 +<font color="red">ANSWER: The data flow diagram shown in Fig. 2 is essentially the same as it was for Project 3. However, the control flow diagram shown in Fig. 3 now consists of three independent programs. The background code initializes the system. The two foreground processes run as independent programs and run to a termination.</font>
 +</ol>
 +</html>
 +{{ :learn:microprocessor:tutorials:pic32-interrupts:interrupt-dfd.png?nolink&500 |Figure 2. Data flow diagram.}}
 +
 +{{ :learn:microprocessor:tutorials:pic32-interrupts:interrupt-cfd.png?nolink&500 |Figure 3. Control flow diagram.}}
 +
 +<html>
 +<ol start="2">
 +<li>Explain how the oscilloscope capture required for step 4 demonstrates that your program implements a nested interrupt preemption scheme.</li>
 +</br>
 +<font color="red">ANSWER: The signal for LEDC is high during the period that the Change Notice interrupt is being served. The signal for LEDA continues to toggle due to servicing the Timer 1 interrupt. Hence, the timer interrupt is interrupting the Change Notice interrupt.</font>
 +</br></br>
 +
 +<li>What are the requirements that dictate which sections of code must be protected from interrupts?</li>
 +</br>
 +<font color="red">Port B is changed in the Timer ISR (changing LEDA and SM1 through SM4) and LEDC is modified in the Change Notice ISR. If the instruction to modify the LEDC bit of Port B is not atomic (meaning that the order of execution cannot be changed), then it would be possible that a Timer 1 interrupt could change the contents of the LATB register in between instructions in the Change Notice ISR. Two of the three conditions needed for requiring protecting code are met: using a global variable (LATB) and modification in two ISR operating at different levels. If the modification of the global variable is not atomic, then the third condition is met and the code will need to be protected.</font>
 +</br></br>
 +
 +<li>What constitutes the worst-case latency for systems that use polling to detect events?</li>
 +</br>
 +<font color="red">ANSWER: It is the main function loop time—all functions in the main function while(1) loop must be completed within the required time or some functions will be executed more slowly that the design requires.</font>
 +</br></br>
 +
 +<li>Explain why the stepper motor is potentially running at a more accurate and consistent speed compared to the Project 4 implementation.</li>
 +</br>
 +<font color="red">ANSWER: The interrupt that causes the stepper motor to step is at the highest level. The latency is constant and predictable regardless of when the interrupt occurs. Hence the latency between the Timer 1 interrupt and the time when the stepper motor actually steps is always the same.</font>
 +</br></br>
 +
 +<li>Discuss the advantages and disadvantages of polling versus interrupts in real-time control.</li>
 +</br>
 +<font color="red">ANSWER: The C code to implement polling is relatively simple to write and verify. The C code to setting up and ISR can be confusing to someone who is unfamiliar with the PIC32 processor. There are no memory requirements to store the processor context. Systems that do not use interrupts are deterministic albeit predictably slow.</font>
 +</br></br>
 +
 +<li>Describe how you would change the Project 5 program to allow you to control the stepper motor at speeds other than those that are multiples of one millisecond.</li>
 +</br>
 +<font color="red">ANSWER: Increase the Timer 1 interrupt frequency.</font>
 +</br></br>
 +
 +<li>Why are interrupt service routines restricted so that no variables can be passed to or returned from the function?</li>
 +</br>
 +<font color="red">ANSWER: Since one cannot predict when the ISR code will be executed, there is no way to prepare the processor registers to receive or return data. The only means of passing data to and from ISRs is by using global variables.</font>
 +</br></br>
 +</ol>
 +</html>
  
-{{tag>learn microprocessors tutorial uno32 uc32 max32 debouncing rc-filter resistors capacitors mpide}}+{{tag>learn microprocessors tutorial pro-mx7 chipkit-pro pic32 interrupts }}