Timing Considerations - ST STM32F103 Series Application Note

How to use the high-density microcontroller to play audio files with an external i2s audio codec
Hide thumbs Also See for STM32F103 Series:
Table of Contents

Advertisement

Implementation example
Use the STMicroelectronics DFU demonstration firmware to compile any audio file and
load it into the memory (for more details, refer to the DFU section in the STM3210E-
EVAL evaluation board demonstration user manual). Once this DFU image is loaded,
the file address has to be set (using the AUDIO_FILE_ADDRESS constant in the
main.h file) and the application note firmware can then run correctly.
Use a different application to load a wave file into the appropriate memory. The file
address has to be stored and used as input when calling the I2S_CODEC_Init
function. If the file is in Mono format, make sure that the first address is an even
number.
2.3.3

Timing considerations

Except during the configuration phase, all the programs run through interrupt subroutines.
This may be convenient to implement other tasks or to add some options (additional
displays, computing, audio encoding/decoding, etc.). Thus, some timing considerations are
to be respected.
The audio stream sampling frequency is the major timing factor. But audio frequencies are
many times slower than the frequencies of other communication IPs (for instance I
up to 400 kHz, SPI at up to 18 MHz, etc.), which means that timing constraints are not very
tough.
The program must be able to release an audio data (16 bits) every 8/16/22.05/44.1/48 kHz.
This timeout includes the reading of data from the memory, the update of the stream status,
the increment of indexes and the information display update. If other tasks are implemented
(such as decoding operations), the period of time taken by all these operations has to be
inferior to the period between two data-sending operations (two SPI TXE interrupts in I
mode).
Interrupt priority
Set the SPI interrupt (TXE in I
interrupt takes a very short and deterministic time, it can have higher priority. Example:
the systick interrupt).
Memory accesses
Mainly, two operations should be as short as possible:
Memory read operation: depending on the memory type, and the memory interface
configuration, reading the audio data from the file located in the memory could be a
long operation. In some cases, it may be necessary to optimize this operation (add
buffers, increase interface frequency, use DMA, etc.).
Display update: this operation consists in writing data into the LCD RAM. Write access
to this RAM may also be long when many information are to be updated. This operation
is optimized in the demo application (group/ungroup information, create a separate
event for each information update, etc.).
Function calls
In the interrupt file (stm32f10x_it.c), most handlers perform calls to i2s_codec
driver functions or main.c functions. In order to optimize time, some calls can be
replaced by the body of the function itself (with specific modifications, depending on the
application requirements).
22/26
2
S mode) as the highest-priority NVIC channel (if another
AN2739
2
C runs at
2
S

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32F103 Series and is the answer not in the manual?

Questions and answers

Table of Contents