Hi Guys - I've been playing around with a MAX541 audio DAC chip (datasheet here) and my TM4C123G LaunchPad lately. I've got audio output working fine, but I'm now trying to get it to play different sine wave tones that are calculated "on the fly" depending on the pitch the user wants to hear.
The way I've designed it is by setting up a "multi-shot" SysTick interrupt that calls the ISR every ~1500 ticks. The ISR calculates the current sample value and sends it to the MAX541 DAC chip using SSI.
The problem I'm running into is that the pitch I hear is not constant. It slowly drops in pitch. What I'm fairly certain is happening is that my "on the fly" sample calculation is taking too long and thus causing a delay in getting the sample value to the DAC for output.
I'm fairly certain about this because I can pre-calculate a single period of sine wave samples into an array - before starting audio playback - then after starting audio playback simply loop through them, sending the sample value at the current index to the DAC and the pitch remains constant in this case.
When using my "on the fly" method, I believe the delay is likely caused by the sin() call from math.h that I need to do when calculating the current sample value. I've stepped through the code for this function and it runs through MANY instructions.
I'm wondering if anyone has any thoughts or suggestions of any possibilities of getting this to work without the latency issue?