AN: Capstone Dive Computer Example - Quantum Leaps
AN: Capstone Dive Computer Example - Quantum Leaps
AN: Capstone Dive Computer Example - Quantum Leaps
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Application Note:<br />
<strong>Capstone</strong> <strong>Dive</strong> <strong>Computer</strong> <strong>Example</strong><br />
www.state-machine.com<br />
(12) The transmit pin GPIO3.4 is configured as output, alternative function 3 (UART0 Tx) using the<br />
ST driver library interface.<br />
(13) The UART0 is not properly configured using the ST driver library interface.<br />
(14) The QS filters are setup (see Chapter 11 in [PSiCC2] as well as “QP Reference Manual”<br />
online).<br />
(15) The QS_onStartup() callback returns 1, meaning that the QS initialization was successful.<br />
(16) The QS_onCleanup() callback is empty for MSP430 (the application never exits).<br />
(17-21) The QS_onGetTime() callback provides a fine-granularity timestamp. The timestamp is discussed<br />
in the next section.<br />
(22) 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.<br />
(23) The implementation of QS for STR912 uses the block-oriented QS-buffer interface<br />
QS_getBlock(), which provides up to 16 bytes to fill the FIFO of the UART (see Chapter 11 in<br />
[PSiCC2]).<br />
(24) The QS_onFlush() callback busy-waits in-line until the transmit buffer is empty.<br />
(25) The data byte is inserted into the UART0 data register.<br />
3.1 QS Time Stamp Callback QS_onGetTime()<br />
The platform-specific QS port must provide function QS_onGetTime() (Listing 5(17-21)) that returns<br />
the current time stamp in 32-bit resolution. To provide such a fine-granularity time stamp, the BSP<br />
uses the free running Timer 3, which is the same timer already used for generation of the system<br />
clock-tick interrupt.<br />
NOTE: The QS_onGetTime() callback is always called with interrupts locked.<br />
Figure 7 shows how the Timer 3 Count Register (TIM3->CNTR) reading is extended to 32 bits.<br />
The drawing below shows a free running Timer 3 Count Register (TIM3->CNTR) that counts up from<br />
0 to 0xFFFF and rolls over to 0. If the system tick rate is faster than the rollover rate then you<br />
could ‘oversample’ this free-running timer by reading it in the clock tick ISR.<br />
The 32-bit variable l_currTime32 contains the sum of the 16-bit deltas from each readout of the<br />
free running Timer 3 Count Register. Because of unsigned 16-bit arithmetic used in Listing 5(19),<br />
even a ‘small’ current value minus a ‘large’ previous value still results in the proper delta. Note that<br />
QS_onGetTime() can actually be called at just about any time and thus, also needs to update<br />
l_currTime32 before it returns the current value.<br />
Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />
25 of 29