TheSlowGrowth Posted May 18, 2014 Report Share Posted May 18, 2014 Hi! For my current project, I need to output a whole lot of analog audio signals from a STM32F4 core. I can't use I2S - it has too few channels. Instead, I want to hook up a chain of DACs to an SPI pin and supply them with their new values from a task in the software. For this I need a stable timing reference that is capable of calling a callback function with at least 40kHz. The sample rate can be changed accordingly - I don't rely on exactly 44,1kHz or anything like that. Now I wonder, what to use as a timing reference. AFAIK, the MIOS32 timers are µs-accurate, but I wonder if they are stable = have low jitter. If not, what else could I use as a timing reference? Thanks The Slow Growth Quote Link to comment Share on other sites More sharing options...
TK. Posted May 18, 2014 Report Share Posted May 18, 2014 Hi, the MIOS32 timers are the best choice for this purpose. You won't notice jitter if the priority is set to MIOS32_IRQ_PRIO_HIGHEST This means, that no other interrupt routine could affect the execution time. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
TheSlowGrowth Posted May 19, 2014 Author Report Share Posted May 19, 2014 (edited) Okay, thats good news. One more question: During one timer callback I have to make multiple SPI transmissions. It is not a good idea to program a task with the highest possible priority that blocks until the hardware is ready for the next transmission. Unfortunately the DMA callback runs at a lower priority (MIOS32_IRQ_PRIO_HIGH) and might be interrupted by other hardware tasks with the same settings, which then causes jitter for the following SPI transmissions to the DAC. I see two possible solutions for this: A) Let the callback run at MIOS32_IRQ_PRIO_HIGHEST. (How can I do this, it seems to be hard coded in MIOS32?) B) Suspend the timer task once it has started the DMA and resume it, once the DMA is ready. The problem is, that I need a highest- priority callback for this as well... It would be cool, if the SPI functions could suspend the task they came from when no callback is supplied. Right now, they just block with a while() loop. What would you do? Thanks you for your help! Edited May 19, 2014 by TheSlowGrowth Quote Link to comment Share on other sites More sharing options...
TheSlowGrowth Posted May 19, 2014 Author Report Share Posted May 19, 2014 Nevermind - I have a solution... My DAC has a syncronization input that allows to load all channels on a positive edge. I can simply push the data in with a regular SPI task and only need the pull the pin high with the jitter-free timer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.