Hello everyone,
I have a problem with this code, wich I have modified due
to understand how the Tx interrupt works on serial communication.
//******************************************************************************
// MSP430F21x2 Demo - USCI_A0, UART 9600 Full-Duplex Transceiver, 32kHz ACLK
//
// A. Dannenberg
// Texas Instruments Inc.
// April 2006
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A
//******************************************************************************
#include "msp430x21x2.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1OUT = 0x00; // P1.0/1 setup for LED output
//P1DIR = 0x03;
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x03; // 32kHz/9600 = 3.41
UCA0BR1 = 0x00;
UCA0MCTL = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IFG2 &= ~(UCA0TXIFG+UCA0RXIFG);
IE2 |= UCA0RXIE + UCA0TXIE; // Enable USCI_A0 TX/RX interrupt
__enable_interrupt();
//__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/ interrupts enabled
while(1);
}
// USCI A0/B0 Transmit ISR
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
UCA0TXBUF = 'a'; // Read, justify, and transmit
IFG2 &= ~UCA0TXIFG;
}
// USCI A0/B0 Receive ISR
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
__no_operation();
}
The problem is that UCA0TXIFG bit never sets to "1" during program execution, but as I have understand from userguide
this bit serve to know when the serial is ready to transmit another character.
In this example, wich is pretty useless code, during debug the program may send continuosly character "a"
within serial com, but it doesn't. I don't understand why.
Sorry for my bad english.
Thanks
Max