2024-07-16 03:41 AM - edited 2024-07-16 03:56 AM
Hi,
I am working on a project to control BLDC motor so I configured the TIM1 as shown below:
I have selected the TGRO trigger event selection to be "Update Event". I have confusion now because when the counter mode is "Center Aligned Mode 3" the update event will be occured twice 1 for underflow(counting down) and 1 for overflow (counting up) in this scenario which event will trigger the ADC?
ADC:
I have configured the ADC as shown below:
in the external trigger I have set "Timer 1 Capture Compare 1 Event" now this where the confusion is. What this trigger source means that every time there is update event on timer 1 it will trigger?. also I want more explanation regarding all these trigger events with a diagram would be great:
My objective is to trigger the adc at the start of PWM cycle and when the ADC conversion is finished generate an interrupt to run my FOC code in a bare metal configuration.
I am using ST controller for the first time so please help me get this up and running.
if there is any example then please let me know I can follow it or an application note.
Also I want the ADC to single scan of all the channels not contineous conversion.
2024-07-16 04:14 AM
Hi,
Figure 143. "Center-aligned PWM waveforms" in Reference Manual RM0390 Rev 6 is your friend. Choose an OCxREF for TRGO. You can use CH4 for adjusting the sampling point. Choose rising or falling edge (or both) in ADC trigger.
hth
KnarfB
2024-07-16 04:30 AM
Hi KnarfB,
Thank you very much for your help.
does the channel 4 of Tim 1 can trigger ADC? as I dont see as an option please see below
also OC1REF refers to channel 1 and OC2REF refers to channel 2 If i am correct.
please check the above diagram if it is correct.
is there an example associated to this type of configuration?
Thanks,
2024-07-16 09:08 AM
You're right, TIM1 can't. However, for TIM2, TIM3, TIM8 you can select OC4REF.
2024-07-17 03:46 AM - edited 2024-07-17 03:57 AM
Hi KnarfB,
That make sense, and I will sychronize Tim2 and Tim1. I will give it a try and see how it works out.
Thanks,