03.11.2014 Views

QDK-nano PIC24/dsPIC-C30 - Quantum Leaps

QDK-nano PIC24/dsPIC-C30 - Quantum Leaps

QDK-nano PIC24/dsPIC-C30 - Quantum Leaps

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>QDK</strong>-<strong>nano</strong><br />

<strong>PIC24</strong>/<strong>dsPIC</strong>-<strong>C30</strong><br />

www.state-machine.com/pic<br />

Figure 7: Triggering the INT0 interrupt from the MPLAB debugger<br />

4.4.1 Interrupt Nesting Test<br />

The first interesting test is verifying that the preemptive scheduler QK_schedule_() is not called in a<br />

nested interrupt, but is called when the interrupt returns to the task level.<br />

To test this scenario, you place a breakpoint inside the _INT0Interrupt() and also inside the<br />

_T2Interrupt() ISR. When the breakpoint in the _T2Interrupt() is hit, you remove the original<br />

breakpoint and place another breakpoint at the very next machine instruction (use the Disassembly<br />

window) and also another breakpoint on the first instruction of the QK_schedule_() function. Next you<br />

trigger the INT0 interrupt per the instructions given in the previous section. You hit the Run button.<br />

The pass criteria of this test are as follows:<br />

1. The first breakpoint hit is the one inside the _INT0Interrupt() function, which means that the INT0<br />

ISR preempted the _T2Interrupt() ISR.<br />

2. The second breakpoint hit is the one in the _T2Interrupt(), which means that the Timer2 ISR<br />

continues after the _INT0Interrupt() completes.<br />

3. The last breakpoint hit is the one in QK_schedule_(), which means that the scheduler is called only<br />

after all interrupts are processed.<br />

You need to remove all breakpoints before proceeding to the next test.<br />

4.4.2 Task Preemption Test<br />

The next interesting test is verifying that tasks can preempt each other. You set a breakpoint anywhere in<br />

the Philosopher state machine code. You run the application until the breakpoint is hit. After this<br />

happens, you remove the original breakpoint and place another breakpoint at the very next machine<br />

instruction (use the Disassembly window). You also place a breakpoint inside the _INT0Interrupt()<br />

interrupt handler and on the first instruction at the first instruction of the QK_schedule_() function. Next<br />

you trigger the INT0 interrupt per the instructions given earlier. You hit the Run button.<br />

The pass criteria of this test are as follows:<br />

1. The first breakpoint hit is the one inside the _INT0Interrupt() function, which means that INT0 ISR<br />

preempted the Philospher task.<br />

Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />

22 of 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!