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 />

return (uint8_t)1; /* indicate successfull QS initialization */<br />

}<br />

/*..........................................................................*/<br />

(9) void QS_onCleanup(void) {<br />

}<br />

/*..........................................................................*/<br />

(10) void QS_onFlush(void) {<br />

uint16_t b;<br />

while ((b = QS_getByte()) != QS_EOD) { /* next QS trace byte available */<br />

while (U2STAbits.UTXBF != 0U) { /* TX Buffer full */<br />

}<br />

U2TXREG = (uint8_t)b; /* stick the byte to TXREG for transmission */<br />

}<br />

}<br />

/*..........................................................................*/<br />

/* NOTE: invoked within a critical section (inetrrupts disabled) */<br />

(11) QSTimeCtr QS_onGetTime(void) {<br />

(12) if (_T2IF == 0) {<br />

(13) return l_tickTime + (uint32_t)TMR2;<br />

}<br />

else {<br />

(14) return l_tickTime + BSP_TMR2_PERIOD + (uint32_t)TMR2;<br />

}<br />

}<br />

#endif /* Q_SPY */<br />

(1) The QS instrumentation is enabled only when the macro Q_SPY is defined<br />

(2) The l_tickTime variable is used to hold the 32-bit-wide the timestamp at tick and is updated in the<br />

system clock tick ISR.<br />

(3) This enumeration defines application-specific QS trace record(s), to demonstrate how to use them.<br />

(4) You need to define the QS_init() callback to initialize the QS software tracing.<br />

(5) You should adjust the QS buffer size (in bytes) to your particular application<br />

(6) You always need to call QS_initBuf() from QS_init() to initialize the trace buffer.<br />

(7) This block of code sets up UART2 to output data at the desired baud rate and standard format<br />

(8N1).<br />

(8) The QS filters are set-up statically.<br />

(9) The QS_onCleanup() callback performs the cleanup of QS. Here nothing needs to be done.<br />

(10) The QS_onFlush() callback flushes the QS trace buffer to the host. Typically, the function busywaits<br />

for the transfer to complete. It is only used in the initialization phase for sending the QS<br />

dictionary records to the host (see please refer to “QSP Reference Manual” section in the “QP/C<br />

Reference Manual” an also to Chapter 11 in [PSiCC2])<br />

7.1 QS Time Stamp Callback QS_onGetTime()<br />

The platform-specific QS port must provide function QS_onGetTime() (Listing 12(11)) that returns the<br />

current time stamp in 32-bit resolution. To provide such a fine-granularity time stamp, the <strong>PIC24</strong>/<strong>dsPIC</strong><br />

port uses the Timer2, which is the same timer already used for generation of the system clock-tick<br />

interrupt.<br />

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

31 of 35

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

Saved successfully!

Ooh no, something went wrong!