SWRU543B January 2019 – June 2025 CC3230S , CC3230SF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
I2S on the CC32xx device acts as master providing frame-sync and bit clock to the slave, and can operate in two modes: transmit-only mode and synchronous transmit–receive mode.
In transmit-only mode, the device is only configured to transmit data. In synchronous transmit–receive mode, the device is configured to transmit and receive in a synchronous manner. In both cases the data transmitted and received is in sync with the frame-sync and bit clock signals generated internally by the I2S module.
This section shows a module initialization and configuration example for each mode supported to transmit and receive 16-bit, 44.1-kHz audio.
BitClock = (Sampling_Frequency * 2 * bits/sample)BitClock = (44100 * 2 * 16) = 1411200 HzPRCMI2SClockFreqSet(14112000)I2SConfigSetExpClk(I2S_BASE, 14112000, 1411200, I2S_SLOT_SIZE_16|I2S_PORT_CPU.The second parameter, I2S_SLOT_SIZE_16|I2S_PORT_CPU, sets the slot size and chooses the port interface on which the I2C module should expect the data.
I2SIntRegister(I2S_BASE, I2SIntHandler)
I2SIntEnable(I2S_BASE,I2S_INT_XDATA)
I2SSerializerConfig(I2S_BASE, I2S_DATA_LINE_0,I2S_SER_MODE_TX, I2S_INACT_LOW_LEVEL) I2SEnable(I2S_BASE, I2S_MODE_TX_ONLY)I2SIntEnable(I2S_BASE,I2S_INT_XDATA)I2SSerializerConfig(I2S_BASE, I2S_DATA_LINE_0, I2S_SER_MODE_TX, I2S_INACT_LOW_LEVEL)
I2SSerializerConfig(I2S_BASE, I2S_DATA_LINE_1, I2S_SER_MODE_RX, I2S_INACT_LOW_LEVEL)
I2SEnable(I2S_BASE, I2S_MODE_TX_RX_SYNC)void I2SIntHandler()
{
unsigned long ulStatus;
unsigned long ulDummy;
// Get the interrupt status
ulStatus = I2SIntStatus(I2S_BASE);
// Check if there was a Transmit interrupt; if so write next data into the tx buffer and acknowledge
// the interrupt
if(ulStatus
&I2S_STS_XDATA)
{
I2SDataPutNonBlocking(I2S_BASE,I2S_DATA_LINE_0,0xA5)
I2SIntClear(I2S_BASE,I2S_STS_XDATA);
}
// Check if there was a receive interrupt; if so read the data from the rx buffer and acknowledge
// the interrupt
if(ulStatus
&I2S_STS_RDATA)
{
I2SDataGetNonBlocking( I2S_BASE, I2S_DATA_LINE_1,
&ulDummy);
I2SIntClear(I2S_BASE,I2S_STS_RDATA);
}
}