I have a question on concurrent use of UART and SPI.
Since the USCI has 2 modules (USCI_A and USCI_B), it seems
that I can use both concurrently.
However, the interrupt vector is shared with 1 vector
named as vector=USCIAB0TX_VECTOR (or vector=USCIAB0RX_VECTOR),
should I use this vector for both of UART and SPI with
if sentence?
The following is some sample program which I came up with,
for using UART and SPI.
Is this the right way to use both of UART and SPI? Or are
there any way to split the interrupt vector?
----------------
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
if(IFG2&UCA0TXIFG) { // UART (USCI_A)
// process for UART
UCA0TXBUF = zbuf;
} else if(IFG2&UCB0TXIFG) { // SPI (USCI_B)
// process for SPI
UCB0TXBUF = zbuf;
}
// where zbuf is some buffer to be sent
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
if(IFG2 & UCA0RXIFG) { // UART (USCI_A)
// process for UART
zbuf = UCA0RXBUF;
} else {
// process for SPI
zbuf = UCB0RXBUF; // SPI (USCI_B)
}
}