Recording and Data Transmission
Initially, we attempted to use the Arduino IDE to code, however this proved to be untenable as the project proceeded. With sound recording being a low-level, time-sensitive procedure that requires a constant sampling rate, it seemed necessary to use an external audio-recording library, only to discover that there were none which supported the Arduino MKR1000’s Cortex-M0+ core. The Arduino standard libraries could not provide us any control over the frequency with which analog data was being read. At the same time, inconsistencies were found within Arduino’s native code which made analog reads inaccurate.
In spite of this host of issues, we found it important to keep using the MKR1000 due to its highly compact build and low-power consumption. Hence, learning some C, C++, and basics of hardware/firmware coding, we wrote a simple library for audio recording using Atmel Studio 7, making use of Arm’s Cortex Microcontroller Software Interface Standard (CMSIS) for smoother editing of registries. Briefly, it involves the use of an event-driven synchronous Timer Counter to trigger an interrupt at every sampling period, directing the ADC to read and convert a pulse in 16-bit resolution, which is then stored into a ping-pong buffer. Upon the filling of a buffer, the DMA will transfer the 512-byte data block to the SPI’s data registry, where it is then transferred to the shift register to be shifted out to the SD card. This procedure attempts to reduce CPU overhead as much as possible to reduce power consumption and also, much more significantly, arose from the fact that it was necessary for us to use software multi-threading due to the simultaneity of our processes.