Part Number: LP-MSP430FR2476
I am trying to setup SPI master transactions based of off eusci_a_spi_ex1master.c file. This file shows enabling the SPI RX interrupt, however it also checks for the TX interrupt though not explicitly enabled. How does the Tx interrupt work? I don't understand how to setup the SPI RX ISR. The RX ISR is triggering after the fifth transaction, I can get a breakpoint to halt. However,
RXData = EUSCI_A_SPI_receiveData(EUSCI_A1_BASE); is showing a value of 0 for RXData. I don't have a scope on hand, I don't understand why the data is not showing up?
Thanks,
Priya
/*
* Initialize the SPI peripheral on EUSCI A1
*/
void init_spi_peripheral()
{
//Initialize Master
EUSCI_A_SPI_initMasterParam param = {0};
param.selectClockSource = EUSCI_A_SPI_CLOCKSOURCE_SMCLK;
param.clockSourceFrequency = CS_getSMCLK();
param.desiredSpiClock = 1000000;
param.msbFirst = UCMSB;
param.clockPhase = UCCKPH;
param.clockPolarity = 0;
param.spiMode = EUSCI_A_SPI_3PIN;
EUSCI_A_SPI_initMaster(EUSCI_A1_BASE, ¶m);
EUSCI_A_SPI_enable(EUSCI_A1_BASE);
}
void CheckUSCI_A1_TxReady(void){
//USCI_A1 TX buffer ready?
while (!EUSCI_A_SPI_getInterruptStatus(EUSCI_A1_BASE,
EUSCI_A_SPI_TRANSMIT_INTERRUPT));
}
void MaximUARTDaisyChainInitStart(void){
daisyChainInit = 1;
//USCI_A1 TX buffer ready?
CheckUSCI_A1_TxReady();
//Transmit Data to slave
for (i = 0; i < 2; i++)
EUSCI_A_SPI_transmitData(EUSCI_A1_BASE, DCInit_transaction1[i]);
TXData++;
CheckUSCI_A1_TxReady();
//Enable Rx Interrupt flags
for (i = 0; i < 2; i++)
EUSCI_A_SPI_transmitData(EUSCI_A1_BASE, DCInit_transaction2[i]);
TXData++;
CheckUSCI_A1_TxReady();
//Clear receive buffer
EUSCI_A_SPI_transmitData(EUSCI_A1_BASE, DCInit_transaction3);
TXData++;
CheckUSCI_A1_TxReady();
//Wakeup UART slave devices
for (i = 0; i < 2; i++)
EUSCI_A_SPI_transmitData(EUSCI_A1_BASE, DCInit_transaction4[i]);
TXData++;
CheckUSCI_A1_TxReady();
//Wait for all UART slave devices to wake up
EUSCI_A_SPI_transmitData(EUSCI_A1_BASE, DCInit_transaction5);
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
init_gpio(); // Set up IO pins
init_clock(); // Set up the system clocks for 16 MHz (on the MSP430)
// Setup peripheral(s) now that gpio and clocks are setup
init_spi_peripheral(); // Init Maxim spi peripheral
//Clear receive interrupt flag
EUSCI_A_SPI_clearInterrupt(EUSCI_A1_BASE,
EUSCI_A_SPI_RECEIVE_INTERRUPT
);
// Enable USCI_A1 RX interrupt
EUSCI_A_SPI_enableInterrupt(EUSCI_A1_BASE,
EUSCI_A_SPI_RECEIVE_INTERRUPT);
//Wait for slave to initialize
__delay_cycles(100);
TXData = 0x1; // Holds TX data
MaximUARTDaisyChainInitStart();
__bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
__no_operation(); // Remain in LPM0
return 0;
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A1_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(USCI_A1_VECTOR)))
#endif
void USCI_A1_ISR(void)
{
if (USCI_SPI_UCRXIFG){
RXData = EUSCI_A_SPI_receiveData(EUSCI_A1_BASE);
if (daisyChainInit == 1 && (TXData == 0x5)){
if (RXData == 0x21){
TXData++;
}
}
//Delay between transmissions for slave to process information
__delay_cycles(40);
}
}
PS: I know the receive works with a evaluation GUI for these evaluation board transactions. It is something about the MSP430 SPI I don't have down correctly.