6.2 Record Subroutine

The record subroutine is shown in Figure 6-3. The flowchart on the left indicates the functionality in software while the one on the right indicates hardware functionality. The record subroutine consists of the following steps:

  1. As soon as the program enters Record mode, it erases the entire allocated memory to start a fresh recording.
  2. The target memory is prepared to perform write operation. The ADC is turned on. The DMAs used to record and store audio are reset. The sampling timer is turned on.
  3. Once the sampling timer is turned on, with every tick an ADC conversion is performed and stored in the ping-pong buffer via DMA.
  4. When one of the ping-pong buffers is full, it signals the software to transfer the buffer into the target memory. Refer to Ping-Pong Buffers for details on ping-pong buffer transfer.
  5. While software is busy transferring one of the ping-pong buffer’s content into memory, the other ping-pong buffer is being populated by the ADC and DMA. Refer to Ping-Pong Buffers for details on ping-pong buffer transfer. Refer to Data Transfer from ADC to Ping-Pong Buffers, Data Transfer from Ping-Pong Buffers to External Memory and Data Transfer from Ping-Pong Buffers to Internal Memory for details on memory operations.
  6. The recording is stopped when the button is pressed again or the memory becomes full. To close the recording session, the sampling timer is stopped, ADC is disabled and the audio metadata is saved in the EEPROM.
Figure 6-3. Record Subroutine