Change the frequency of the square signal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-27 10:02 AM
Hi
I am working on changing the frequency of the square signal which comes from STM32F4. I used Timer and ADC simultaneously where I change ARR and CCR1 accordingly to change the frequency. When I use an incremental loop for these values I can get different frequency but When I add ADC (continuous mode) in the fly of the program, the output gives me just one frequency and when I press the reset button with changing variable resistor I get updated value. How can I solve this issue? Is there another method to do that?
this is my code:
-----------------------------------------------------------------------
while (1)
{
AA=HAL_ADC_GetValue(&hadc1);
DT=0.5*AA;
htim3.Instance->ARR=AA;
htim3.Instance->CCR1=DT;
}
-------------------------------------------------------------------------
I will hear from you.
Thanks
Solved! Go to Solution.
- Labels:
-
STM32 Motor Control
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-01 6:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-27 10:31 AM
HAL_ADC_GetValue only reads the last converted channel, it doesn't start a new conversion. Assuming you've set the ADC to convert continuously, your method should work.
From the reference manual:
> It may be useful to let the ADC convert one or more channels without reading the data each
time (if there is an analog watchdog for instance). For that, the DMA must be disabled
(DMA = 0) and the EOC bit must be set at the end of a sequence only (EOCS = 0). In this
configuration, overrun detection is disabled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-27 12:53 PM
I did ADC convert Continuously mode. But I could not get any change until I press reset button to change frequency so the code can not follow the change of variable resistor's voltage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-27 3:56 PM
How are you initializing and starting ADC conversions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-01 6:31 AM
I initialized ADC by using continuous mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-15 2:51 AM
Dear @AAbed.1​
Do you have still this problem to solve?
And just in case, if not, do not hesitate to share the final solution you found.
Best regards
Laurent Ca...
==
Dear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-26 1:52 AM
Dear @AAbed.1​
I guess you don't have to solve this problem anymore, therefore I consider this thread closed.
If not, feel free to reopen it by posting an answer.
Best regards
Laurent Ca...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-01 6:24 PM
Thanks
I solved it by using single mode ADC.
