
QDK™
R8C/Tau-NC30
www.state-machine.com/m16c
* b5 NCH Data output select bit
* b6 CKPOL Clock polarity selected,TX falling edge,RX rising edge
* b7 UFORM MSB first
*/
u0c0 = 0x00;
u0tb = u0rb; /* clear UART0 receive buffer by reading it */
u0tb = 0; /* clear UART0 transmit buffer */
/* 00000101 UART0 transmit/receive control register 1
* b0 TE Transmit Enable Bit
* b1 TI Transmit buffer empty flag,
* b2 RE Receive enable bit,
* b3 RI Receive complete flag,
* b4 U1IRS Transmit buffer empty select,
* b5 U1RRM Disable continous receive mode,
* b6:b7 Reserved, set to 0
*/
u0c1 = 0x05;
/* start the 16-bit Timer D, channel 1 to provide the time stamp for QS */
(9) trdcr0 = 0x03; /* Timer RD, channel 0 as free running counter from f8 */
/* setup the QS filters... */
(10) QS_FILTER_ON(QS_ALL_RECORDS);
. . .
. . .
(11) return (uint8_t)1; /* indicate successfull QS initialization */
}
/*..........................................................................*/
(12) void QS_onCleanup(void) {
}
/*..........................................................................*/
(13) void QS_onFlush(void) {
uint16_t b;
while ((b =
QS_getByte()
) != QS_EOD) { /* next QS trace byte available? */
while (ti_u0c1 == 0) {
}
U0tb = b; /* stick the byte to the TX buffer */
}
}
/*..........................................................................*/
/* NOTE: invoked within a critical section (inetrrupts disabled) */
(14) QSTimeCtr QS_onGetTime(void) {
(15) if (ovf_trdsr0 != 0) { /* overflow flag set? */
(16) ++l_nTimerRDunderflows; /* account for 16-bit underflow (0->0xFFFF) */
(17) ovf_trdsr0 = 0; /* clear the overflow flag */
}
(18) return ((QSTimeCtr)l_nTimerRDunderflows << 16) + (QSTimeCtr)trd0;
}
#endif /* Q_SPY */
Listing 11 QS implementation to send data out of the UART0serial port of the
M16C/R8C
(1) The QS instrumentation is enabled only when the macro
Q_SPY
is defined
(2) You should adjust the QS buffer size (in bytes) to your particular application
(3) You might want to adjust the UART baud rate to your particular system (the 115200 baud rate
works well with the 20MHz f1 clock)
Copyright © Quantum Leaps, LLC. All Rights Reserved.
23 of 26
Comentarios a estos manuales