How to clock while loop STM32F4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-07-01 10:28 AM
Hi, I was wondering how I would go about setting up timing/clocking for the while(1) loop in the main of my program. I would like to set it up to be synchronized with the sample rate of the ADC, as right now the two do not seem to be related. I am using the STM32F4 with the built in ADC.
#clock #loop-timing- Labels:
-
RCC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-07-01 11:40 AM
The point of doing that would be what, exactly?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-07-03 4:00 PM
I am trying to use the STM32 for audio applications, the end goal being to create a dsp effects unit. I'd like to be able to set up a sample rate for the output instead of it being based on however long the code within the while(1) loop takes to execute, which would change based on what kind of processing it is doing.
The main thing I need out of a sample rate is the ability to set up precise delay times, where the number of samples in a delay has a stable relationship to an amount of time. I also need to control the sample rate to prevent memory issues in this application, since if the while loop is running very fast my sampled delay buffer will fill up very quickly and I will not be able to achieve longer delay times. This is my first experience programming microcontrollers, in the past I have mainly worked in a computer environment. Sample rate is always one of the first things that gets set up in my experience with audio programming. Is there a reason that wouldn't apply when using a microcontroller?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-07-03 7:20 PM
Sample rate is always one of the first things that gets set up in my experience with audio programming. Is there a reason that wouldn't apply when using a microcontroller?
Yes, it important in embedded too, but you don't do it counting cycles in a while(1) loop. You'd program a time base via a timer which triggers the ADC to do the conversion at the desired periodicity. With the STM32, doing multiple channels, TIM+ADC+DMA[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Internal%20Clocking%20and%20Sample%20Rate%20on%20STM32F4%20ADC&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx¤tviews=9]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM32Discovery%2fInternal%20Clocking%20and%20Sample%20Rate%20on%20STM32F4%20ADC&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2FAllItems%2Easpx¤tviews=9Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-07-05 7:25 AM
That makes sense. How do I set up a timer? Is there any documentation or examples you can point me to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-07-05 9:33 AM
There are code examples in the SPL and HAL libraries, and I've posted literally dozens of examples to the forum. Avail yourself of Google, Bing, etc.
The Reference Manual documents the technical connectivity and function of the part, it's what I use to understand how it works.[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/stm32f207%20ADC%2BTIMER%2BDMA%20%20Poor%20Peripheral%20Library%20Examples&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=6018]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2Fstm32f207%20ADC%2BTIMER%2BDMA%20%20Poor%20Peripheral%20Library%20Examples&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=6018Up vote any posts that you find helpful, it shows what's working..
