At the beginning of the main program the HAL_Init() function is called to reset
all the peripherals, initialize the Flash interface and the systick.
Then the SystemClock_Config() function is used to configure the system
clock (SYSCLK) to run at 216 MHz.
The I2S peripheral configuration is ensured by the HAL_I2S_Init() function.
This later is calling the HAL_I2S_MspInit()function which core is implementing
the configuration of the needed SPI resources according to the used hardware (CLOCK,
GPIO and NVIC). You may update this function to change I2S configuration.
The I2S communication is then initiated.
The HAL_I2S_Transmit_IT() function allows the transmission of a predefined data buffer
and HAL_I2S_Receive_IT() function allows the reception.
The user can choose between Master and Slave through "#define I2S_MASTER_TRANSMITTER"
in the "main.c" file.
If the Master board is used, the "#define I2S_MASTER_TRANSMITTER" must be uncommented.
If the Slave board is used the "#define I2S_MASTER_TRANSMITTER" must be commented.
For this example the I2S_Buffer_Tx is predefined and the I2S_Buffer_Rx size is same as I2S_Buffer_Tx.
In master board, I2S peripheral is configured as Master Transmitter with Interrupt,
whereas in Slave board, I2S peripheral is configured as Slave Receiver with Interrupt.
The both devices are in Philips standard configuration with 16bit and 48KHz audio frequency.
When the user press on the Tamper Button on the Master Board, the master transmitter
start sending data stored in the I2S_Buffer_Tx buffer while the Slave Board receives
data I2S_Buffer_Rx buffer.
Once the transfer is completed a comparison is done and TransferStatus gives the
data transfer status.
STM32 board's LEDs can be used to monitor the transfer status:
- LED1 turned OFF waiting User push-button to be pressed on master board.
- LED1 turns ON if transmission/reception is complete and OK.
- LED3 turns ON if error is generated.
@note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds)
based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from
a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower)
than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.
@note The application need to ensure that the SysTick time base is always set to 1 millisecond
to have correct HAL operation.
@par Keywords
Audio, I2S, Data Exchange, Interrupt, Philips Standard, Master, Slave
@Note<74>If the user code size exceeds the DTCM-RAM size or starts from internal cacheable memories (SRAM1 and SRAM2),that is shared between several processors,
<20><><EFBFBD><EFBFBD><EFBFBD>then it is highly recommended to enable the CPU cache and maintain its coherence at application level.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The address and the size of cacheable buffers (shared between CPU and other masters) must be properly updated to be aligned to cache line size (32 bytes).
@Note It is recommended to enable the cache and maintain its coherence, but depending on the use case
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> It is also possible to configure the MPU as "Write through", to guarantee the write access coherence.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>In that case, the MPU must be configured as Cacheable/Bufferable/Not Shareable.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Even though the user must manage the cache coherence for read accesses.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Please refer to the AN4838 <20>Managing memory protection unit (MPU) in STM32 MCUs<55>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Please refer to the AN4839 <20>Level 1 cache on STM32F7 Series<65>
@par Directory contents
- I2S/I2S_DataExchangeInterrupt/Inc/stm32f7xx_hal_conf.h HAL configuration file