2012-11-22 11:43 AM
Hi. I hope someone can help me here...
I have been looking at the STM32f4 dac signal generation code. I would like to know how I could change the frequency of the output waveform with a potentiometer or, using the ADC, any other simple sensor ( LDR perhaps..)I was wondering if it is possible to change TIM.Period via the ADC...I am a beginner but if anyone can point me in the right direction that would be nice...?..I am using the STM32f4 discovery and the DACsignals generation code from the peripherals library.I am on a windows machine...Thankyou,STeve.2012-11-22 01:42 PM
''I have been looking at the STM32f4 dac signal generation code''
First, you need to look at how it currently sets its frequency; Then you can think about how to adjust that setting based on the current ADC reading...2012-11-22 04:33 PM
You could use the ADC's EOC interrupt, reading the converted value, and then translate and write the new period into the TIMx->ARR register.
Clever factoring of prescale and period might permit other, and perhaps simpler, alternatives.2012-11-23 07:35 AM
Hi,
This is a method to change generated waveform frequency based on potentiometer value: The idea to generate a wave throw DAC is to use a timer to trig transfers of an input signal to DAC. So the wave frequency is the one of the used timer. Generally, we need to know the prescaler & period to configure the timer. So here, we have to calculate the prescaler & period based on the value read from potentiometer and converted by an ADC to know the new frequency. Each time there is a new frequency value: - stop DAC generation - configure timer with new prescaler and period values - re-start generation I hope this is helpful for you. Cheers, STOne-322012-11-23 10:19 AM
''The idea to generate a wave throogh DAC is to use a timer to trig transfers of an input signal to DAC.''
You mean, transfer samples of an input signal to the DAC? ''So the wave frequency is the one of the used timer.''
No: the timer sets the sample rate - not the wave frequency!