This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Where can I find code examplese of USCI in UART mode and USART in UART mode?
I just want to see the difference between the two.
Very often I use this for UART:
P2SEL |= BIT4+BIT5; // Set UC0TXD and UC0RXD to transmit and receive data
UCA0CTL1 |= BIT0; // Software reset
UCA0CTL0 = 0; // USCI_A0 control register
UCA0CTL1 |= UCSSEL_2; // Clock source SMCLK
UCA0BR0=27; // 1048576 Hz / 38400
UCA0BR1=0; //
UCA0MCTL=0x94; // Modulation
UCA0CTL1 &= ~BIT0; // Software reset
IE2 |=UCA0RXIE; // Enable USCI_A0 RX interrupt
However I am not sure if this is USCI or USART...
PS. I am using MSP430FG4618..
Hi Armen,
you can find code examples for this device here http://www.ti.com/litv/zip/slac118d.
Rgds
aBUGSworstnightmare
The main differenc ebetween the two is the interrupt handling and organization.
USART has separate interrupt vectors and edge-triggered interrupt events, and the IFG adn IE flags are placed on global SFRs, while the USCI has joined vectors, an interrupt vector register and its own registers for all IE and IFG flags. Also, the USCI interrupts are level-triggered. As long as the IFG bit is set (and it won't clear automatically on ISR entry), the interrupt is still pending. You have to manually clear it or implicitely by reading the IV register or e.g. reading the RXBUF/writing to TXBUF.
Another (minor) difference is the oprional oversampling mode: if the source clock is much higher than the baudrate, it can be activated (acts as additional /16) and improves the bit level detection.
There are, however, two versions of the USCI. The older USCI, found in 2x devices, shares RX (and TX respectively) interrupt of A and B module in one ISR while the newer one shares RX an TX of A module and has a separate interrupt for the RX and BX of B module. Also, teh older USCI still uses global IE/IFG register while the newer one has its own IE and IFG register for each submodule (A or B).
Your code seems to be for an older USCI (from the name of UCA... but the usage of IE2)
**Attention** This is a public forum