Hi, I'm new to the MSP430 and I have read the User Manual and I've learned some "theoretical" knowledge like how to set up the clock or how to use Timer A. Then, I've looked at sample codes which actually taught me how to use that knowledge in a more practical way in C. However, when looking at a sample code on USART0 UART 115200 Echo ISR, I can see this
#include <msp430x14x.h>
void main(void)
{
unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 |= XTS; // ACLK = LFXT1 = HF XTAL
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG) != 0); // OSCFault flag still set?
BCSCTL2 |= SELM1+SELM0; // MCLK = LFXT1 (safe)
UCTL0 = CHAR; // 8-bit character
UTCTL0 = SSEL0; // UCLK = ACLK
UBR00 = 0x45; // 8MHz 115200
UBR10 = 0x00; // 8MHz 115200
UMCTL0 = 0x00; // 8MHz 115200 modulation
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
IE1 |= URXIE0; // Enable USART0 RX interrupt
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
P3DIR |= 0x10; // P3.4 output direction
_EINT(); // Enable interrupts
for (;;)
{
_BIS_SR(CPUOFF); // Enter LPM0
_NOP(); // Required only for C-spy
}
}
void usart0_rx (void) __interrupt[UART0RX_VECTOR]
{
while ((IFG1 & UTXIFG0) == 0); // USART0 TX buffer ready?
TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0
}
I think I understand the main function where everything is initialized and then goes into low power mode to loop until interrupted. I think the second function is a interrupt handler for when you receive something through USART0. I think I understand everything inside the function because registers like IFG1, UTXIFG0, TXBUF0 and RXBUF0 are well explained in the manual.
However, what I would like to know is about the function header "void usart0_rx (void) __interrupt[UART0RX_VECTOR". Where do you get the exact syntax to declare the interrupt handler function? There was no C code in the User Manual. Same question for other function headers like "void Timer_A (void) __interrupt[TIMERA0_VECTOR]". Am I missing a manual for C somewhere?