QDK PIC24/dsPIC-C30 - Quantum Leaps
QDK PIC24/dsPIC-C30 - Quantum Leaps
QDK PIC24/dsPIC-C30 - Quantum Leaps
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 />
7.2 QS Trace Output in QF_onIdle()/QK_onIdle()<br />
To be minimally intrusive, the actual output of the QS trace data happens when the system has nothing<br />
else to do, that is, during the idle processing. The following code snippet shows the code placed either in<br />
the QF_onIdle() callback (“Vanilla” port), or QK_onIdle() callback (in the QK port):<br />
Listing 13: QS trace output using the UART0 of the Stellaris LM3S811 MCU<br />
#define UART_TXFIFO_DEPTH 16<br />
. . .<br />
void QK_onIdle(void) {<br />
. . .<br />
#ifdef Q_SPY<br />
(1) while (U2STAbits.UTXBF == 0U) { /* TX Buffer not full */<br />
uint16_t b;<br />
(2) QF_INT_LOCK(dummy);<br />
(3) b = QS_getByte();<br />
(4) QF_INT_UNLOCK(dummy);<br />
(5) if (b == QS_EOD) { /* End-Of-Data reached */<br />
(6) break; /* break out of the loop */<br />
}<br />
(7) U2TXREG = (uint8_t)b; /* stick the byte to TXREG for transmission */<br />
}<br />
#elif defined NDEBUG<br />
__asm__ volatile("disi #0x0001");<br />
Idle(); /* transition to Idle mode, see NOTE03 */<br />
#else<br />
QF_INT_UNLOCK(dummy); /* unlock interrupts, see NOTE01 */<br />
#endif<br />
}<br />
(1) As long as the UTXBF (TX buffer full) flag is not set, the UART2 TX FIFO can accept new bytes.<br />
(2) Interrupts are locked to call QS_getByte().<br />
(3) The function QS_getByte() returns the next byte or QS_EOD (end-of-data) if the QS ring buffer is<br />
empty.<br />
(4) The interrupts are unlocked after the call to QS_getByte().<br />
(5-6) If end-of-data is reached the loop is terminated for this invocation of QK_onIdle().<br />
(7) The byte obtained from the QS buffer is inserted into the UART2 transmit register for transmission.<br />
7.3 Invoking the QSpy Host Application<br />
The QSPY host application receives the QS trace data, parses it and displays on the host workstation<br />
(currently Windows or Linux). For the configuration options chosen in this port, you invoke the QSPY host<br />
application as follows (please refer to “QSP Reference Manual” section in the “QP/C Reference Manual”<br />
an also to Chapter 11 in [PSiCC2]):<br />
qspy –cCOM1 –b38400 –O2 –F2 –S1 –E1 –Q1 –P1 –B1<br />
Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />
33 of 35