F07 DAC gptChangeInterval Issue
Posted: Fri Sep 16, 2016 5:14 pm
I'm using DMA to a DAC on an F07 MCU, which is working well, at least for a constant update interval. I want to use it for generating an AFSK signal, and I was hoping that I could change the frequency by simple updating the interval, but that doesn't seem to be working correctly.
In order to accomplish this, I'm simply calling gptChangeInterval at a fixed interval, currently just ping-ponging between two intervals and looking at the output on a scope. I first tried using a GPT + thread (signaled from the GPT) to change the interval, then, to simplify it, I just started calling gptChangeInterval from within a loop in the main thread. Both methods have the same effect.
What appears to be happening is when the interval is changed, the output either flatlines, or, I think it might actually still be changing, but at a much slower pace, so it looks pretty much like it's flatlining. It also appears to be "flatligning" across multiple interval changes, at least at higher rates of update. For example, if I'm updating at 1ms intervals, I see a bit of sine wave, then a "flatline" that's much longer in duration. If I slow it down to e.g. 1sec updates, it clearly changes frequency, but there are still "flatlines" in between.
Is what I'm trying to do reasonable? I could also skip DMA and use a GPT to output the entire signal manually, but that would be less efficient and more coding.
Is it possible, since I'm setting the interval to a smaller interval half of the time, the TIM couunter is already past that value and it ends up counting until the counter wraps around? That's the only theory that I can come up with.
In order to accomplish this, I'm simply calling gptChangeInterval at a fixed interval, currently just ping-ponging between two intervals and looking at the output on a scope. I first tried using a GPT + thread (signaled from the GPT) to change the interval, then, to simplify it, I just started calling gptChangeInterval from within a loop in the main thread. Both methods have the same effect.
What appears to be happening is when the interval is changed, the output either flatlines, or, I think it might actually still be changing, but at a much slower pace, so it looks pretty much like it's flatlining. It also appears to be "flatligning" across multiple interval changes, at least at higher rates of update. For example, if I'm updating at 1ms intervals, I see a bit of sine wave, then a "flatline" that's much longer in duration. If I slow it down to e.g. 1sec updates, it clearly changes frequency, but there are still "flatlines" in between.
Is what I'm trying to do reasonable? I could also skip DMA and use a GPT to output the entire signal manually, but that would be less efficient and more coding.
Is it possible, since I'm setting the interval to a smaller interval half of the time, the TIM couunter is already past that value and it ends up counting until the counter wraps around? That's the only theory that I can come up with.