30.12.2014 Views

QDK PIC24/dsPIC-C30 - Quantum Leaps

QDK PIC24/dsPIC-C30 - Quantum Leaps

QDK PIC24/dsPIC-C30 - Quantum Leaps

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>QDK</strong><br />

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

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

(3) QK_ISR_EXIT(); /* inform QK about exiting the ISR */<br />

}<br />

(1) The macro QK_ISR() is used before the ISR signature. Here the PSV control is set to no_auto_ps,<br />

which avoids saving and restoring the PSVPAG register. If your ISR body references const variables<br />

or string literals using the constants-in-code memory model, you need to define this argument to<br />

auto_psv.<br />

(2) When software tracing is enabled, the ISR updates the 32-bit time stamp at tick, which is used to<br />

provide a 32-bit time stamp for the trace events.<br />

(3) The macro QK_ISR_EXIT() is invoked at the end of every ISR to perform the asynchronous context<br />

switch, if necessary.<br />

4.2.1 Explanation of ISR code for the preemptive QK kernel<br />

Listing 9 shows the disassembled code for the _T2Interrupt ISR from Listing 8. The highlighted code is<br />

generated by the macros QK_ISR() and QK_ISR_EXIT(). The explanation section immediately following<br />

the listing clarifies the most important points.<br />

Listing 9: Disassembled code for T2Interrupt ISR<br />

72: QK_ISR(no_auto_psv) _T2Interrupt() {<br />

(1) 009F8 F80036 push.w 0x0036<br />

(2) 009FA BE9F80 mov.d 0x0000,[0x001e++]<br />

(3) 009FC 97B84F mov.w [0x001e-8],0x0000<br />

(4) 009FE DE00CD lsr 0x0000,#13,0x0002<br />

(5) 00A00 200010 mov.w #0x1,0x0000<br />

(6) 00A02 DD0001 sl 0x0000,0x0002,0x0000<br />

(7) 00A04 B76993 ior.b 0x0993<br />

(8) 00A06 370002 bra 0x000a0c<br />

(9) 00A08 F80036 push.w 0x0036<br />

(10) 00A0A BE9F80 mov.d 0x0000,[0x001e++]<br />

(11) 00A0C BE9F82 mov.d 0x0004,[0x001e++]<br />

(12) 00A0E BE9F84 mov.d 0x0008,[0x001e++]<br />

(13) 00A10 BE9F86 mov.d 0x000c,[0x001e++]<br />

(14) 00A12 781F88 mov.w 0x0010,[0x001e++]<br />

73: _T2IF = 0; /* clear Timer 2 interrupt flag */<br />

00A14 A9E084 bclr.b 0x0084,#7<br />

74:<br />

75: #ifdef Q_SPY<br />

76: l_tickTime += BSP_TMR2_PERIOD; /* TMR2 overflow */<br />

77: #endif<br />

78:<br />

79: QF_tick(); /* handle all armed time events in QF */<br />

00A16 07027E rcall 0x000f14<br />

80:<br />

81: QK_ISR_EXIT(); /* inform QK about exiting the ISR */<br />

(15) 00A18 800218 mov.w 0x0042,0x0010<br />

(16) 00A1A DE4045 lsr 0x0010,#5,0x0000<br />

(17) 00A1C 600067 and.w 0x0000,#7,0x0000<br />

(18) 00A1E 200011 mov.w #0x1,0x0002<br />

(19) 00A20 DD0800 sl 0x0002,0x0000,0x0000<br />

(20) 00A22 B34010 ior.b #0x1,0x0000<br />

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

20 of 35

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

Saved successfully!

Ooh no, something went wrong!