Upon completing my ventures attempting to use Simulink and the Arduino together with the hardware support package, I am now tryign to port this to the Arduino IDE in C code in order to create something with actual application in the real world. To begin with I aimed to create a transmitter and receiver to send audio data with LEDs.
However, this proved to be a much larger hurdle than I first expected it to. In order to “emulate” sampling in code, one would need to use timer interrupts. This meant physically manipulating the registers inside the MPU. The Uno has a lot of documentation on how to do this with sites such as the following.
The Due on the other hand was not as well documented. Thus I decided to try and implement something with the Uno as a test run before I learned to properly write AVR code. After reading up on the Arduino forums I discovered the following scheme to properly do timer interrupts on the Uno.
The code has been commented for ease of understanding. However I was not able to transmit a square wave of anything higher than around 2kHz on the Uno and thus had to keep looking for working code for the Due. After doing so, I stumbled on the following webpage which details how timer interrupts can be done on the Due.
Even after further testing using the same sort of square wave testing methodology I was only able to create a square wave/trigger that was around 5 kHz. After that I concluded that in order to fully maximize the processing power of the Due, I would have to completely forget about timer interrupts. This is because I need to take advantage of every single instruction that the MPU can process and even doing so I may not be able to transmit and receive data at the desired rate.
With this new scheme, it meant that I would be walking away from the idea of “sampling” data and transmitting data at a certain rate and just work with the max data transfer rate.