www.ti.com
Programming Model
405
SWRU543–January 2019
Submit Documentation Feedback
Copyright © 2019, Texas Instruments Incorporated
Inter-Integrated Sound (I2S) Multichannel Audio Serial Port
PRCMPeripheralClkEnable(PRCM_I2S,PRCM_RUN_MODE_CLK).
b. Reset the module using PRCMPeripheralReset(PRCM_I2S).
c. Set fractional clock divider to generate module input clock of BitRate × 10:
PRCMI2SClockFreqSet(14112000)
d. Configure the internal divider of the module to generate the required bit clock frequency:
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 I
2
C module should expect the data.
e. Register the interrupt handler and enable the transmit data interrupt:
I2SIntRegister(I2S_BASE, I2SIntHandler)
I2SIntEnable(I2S_BASE,I2S_INT_XDATA)
3. Transmit-only mode with interrupts
a. Configure serializer 0 for transmit:
I2SSerializerConfig(I2S_BASE, I2S_DATA_LINE_0,I2S_SER_MODE_TX, I2S_INACT_LOW_LEVEL)
b. Enable the I2S module in transmit-only mode:
I2SEnable(I2S_BASE, I2S_MODE_TX_ONLY)
4. Synchronous transmit–receive mode with interrupts
a. Enable receive data Interrupt:
I2SIntEnable(I2S_BASE,I2S_INT_XDATA)
b. Configure serializer 0 for transmit and serializer 1 for receive:
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)
c. Enable the I2S module in synchronous transmit–receive mode:
I2SEnable(I2S_BASE, I2S_MODE_TX_RX_SYNC)
5. Generic I2S interrupt handler
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);
}
}