PROBLEM: Keystrokes are not echoed in serial Terminal window.
--------------------------------------------------------------------------------------------------
SYSTEM SETUP
DEVICE: G2553 on LaunchPad target board
FIRMWARE DEMO PROGRAM: msp430g2xx3_uscia0_uart_01_9600
OS: Windows Vista 32-bit
CCS: Version: 5.5.0.00077
TERMINAL SOFTWARE: PuTTY, set to COM 8, 9600 Baud, 8 Data bits, 1 Stop Bit, No Parity.
COMPUTER COM PORT 8 Settings: 9600 Baud, 8 Data bits, 1 Stop Bit, No Parity
No Oscilloscope in this lab.
No serial monitoring software is installed.
No external oscillator is connected to the target board.
--------------------------------------------------------------------------------------------------
DESCRIPTION
An MSP430ware demo program is loaded into a G2553 device on an EXP430G2 LaunchPad board. The demo is supposed to simply echo back what it receives from a terminal window. No changes have been made to the program. However, when keystrokes are made, nothing appears in the terminal window, except when the Delete key is pressed. This is what appears in the window when Delete key is pressed ten times: #«&3#«&°d5l²5À#«&3#«&6¶3#«&.
For the physical connection:
1) On the target board I put the RXD and TXD terminals of Jumper 5 into HW UART mode.
2) I connected P1.1 (RXD) from the target to the TXD Pin on the computer’s DB-9 serial connector, and then P1.2 (TXD) to the RXD Pin.
P1.2/UCA0TXD --------------> RXD on COM Port (Pin 2 RXD)
9600 - 8N1
P1.1/UCA0RXD <-------------- TXD on COM Port (Pin 3 TXD)
3) The COM port on my computer is set to the same parameters used in the demo program: 9600 Baud, 8 Data bits, 1 Stop Bit, No Parity.
--------------------------------------------------------------------------------------------------
DEBUGGING SYMPTOMS
While in debug mode, I have added a couple expressions to the watch window: the receive buffer, UCA0RXBUF, and the transmit buffer, UCA0TXBUF. When I step through the ISR, these are the symptoms I see at those registers.
- Only the Delete key generates an interrupt that forces the CPU to enter the ISR. No other keys will generate the interrupt.
- The firmware is able to enter the body of the WHILE condition (line 48) and execute the assignment of UCA0RXBUF to UCA0TXBUF.
- The image below shows the Watch window and its contents after the ISR has been executed. The values 0x0066 and 0x0067 never change while the program runs.
It seems to me that the buffers are not getting filled with character data. And since the Delete key is the only key that triggers an interrupt, but without the ability to exchange a character either way, the signaling across the wire might be suspect.
--------------------------------------------------------------------------------------------------
QUESTION 1
When I press a key on my keyboard, should the character for that key appear in the terminal window twice, with the first instance as an output from my keyboard and the second instance echoed from the device?
QUESTION 2
Why are my keystrokes not echoed in the terminal window?
--------------------------------------------------------------------------------------------------
DEMO PROGRAM
Here is the program that came directly from TI. No changes were made.
//******************************************************************************
// MSP430G2xx3 Demo - USCI_A0, 9600 UART Echo ISR, DCO SMCLK
//
// Description: Echo a received character, RX ISR used. Normal mode is LPM0.
// USCI_A0 RX interrupt triggers TX Echo.
// Baud rate divider with 1MHz = 1MHz/9600 = ~104.2
// ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz
//
// MSP430G2xx3
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.2/UCA0TXD|------------>
// | | 9600 - 8N1
// | P1.1/UCA0RXD|<------------
//
//******************************************************************************
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_1MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}