Part Number: LAUNCHXL-F28379D
void initSPIFIFO()
{
//
// Must put SPI into reset before configuring it
//
SPI_disableModule(SPIA_BASE);
//
// SPI configuration. Use a 500kHz SPICLK and 16-bit word size.
//
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
SPI_MODE_MASTER, 500000, 16);
SPI_enableLoopback(SPIA_BASE);
SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_STOP_AFTER_TRANSMIT);
//
// FIFO and interrupt configuration
//
SPI_enableFIFO(SPIA_BASE);
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF | SPI_INT_TXFF);
SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TX2, SPI_FIFO_RX2);
SPI_enableInterrupt(SPIA_BASE, SPI_INT_RXFF | SPI_INT_TXFF);
//
// Configuration complete. Enable the module.
//
SPI_enableModule(SPIA_BASE);
}
//
// SPI A Transmit FIFO ISR
//
__interrupt void spiTxFIFOISR(void)
{
uint16_t i;
//
// Send data
//
for(i = 0; i < 16; i++)
{
SPI_writeDataNonBlocking(SPIA_BASE, sData[i]);
}
//
// Clear interrupt flag and issue ACK
//
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_TXFF);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP6);
}
//
// SPI A Receive FIFO ISR
//
__interrupt void spiRxFIFOISR(void)
{
uint16_t i;
for(i = 0; i < 16; i++)
{
rData[i] = SPI_readDataNonBlocking(SPIA_BASE);
}
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP6);
}
__interrupt void adcisr(void)
{
static uint16_t p;
sData[p]=ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0); //adc result stored in adcres variable
p++;
if(p==16)
{
p=0;
}
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);//interrupt flag is cleared
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1); //to clear any interrupt flag within PIE group
}
I have tried one exercise in which I want to store ADC result in one array having a size of 16, after 16 ISR that array will be filled and then I want to send that using SPI (FIFO level of 16 defined) and that data need to be stored in another array having SIZE of 16 at receiving end
Is this code (SPI initialization and ISR shown) do the same things or not?
Regards,
Jay
ss