cancel
Showing results for 
Search instead for 
Did you mean: 

Timer and ADC on STM32F429

DetlefS
Senior

Hi,

I want to kick ADC1 IN5 with the Timer TIM2. 

I'm working with CubeIDE.

I select:

ADC1 -> ADC_Regular_Conversion_Mode -> External Trigger Conversion Source  -> Timer 2 Trigger Out event

TIM2 ->  Trigger Output (TRGO) Parameters -> Update Event

But ADC1 does not run, Data Register is constant.

If I kick ADC1 by software everything is fine, I get some noisy numbers.

TIM2 is running, the count register is counting.

Why does TIM2 not kick ADC1 by the TRGO event?

This setup used to work fine on STM32F303. 

What do I miss on the STM32F429?

THX Cheers

Detlef 

1 ACCEPTED SOLUTION

Accepted Solutions
Karl Yamashita
Principal

I took your IOC file and generated a project. I'm not sure if there is a reason you're using PWM with no output for Timer1 but I don't see an Option for the ADC to use an appropriate trigger from Timer1.  I used Timer 3 which the ADC can trigger off the Trigger Out Event. I attached the updated IOC file.

 

I always use DMA so i use HAL_ADC_Start_DMA. But I noticed that you're using  HAL_ADC_Start in which the DR register value does not update. But if I use HAL_ADC_Start_IT, the DR register value updates. 

Either HAL_TIM_Base_Start_IT or HAL_TIM_Base_Start works. But with your Counter Period at 71 (1.69us), it is too fast so the Timer Interrupt keeps the main while loop from running. If you plan to send this ADC value as telemetry data, then HAL_TIM_Base_Start will work best.

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

View solution in original post

18 REPLIES 18
Karl Yamashita
Principal

You haven't mentioned that you've called HAL_TIM_Base_Start_IT

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

I started both TIM and ADC. I printed out the timer count values, they change. So the counter is up and running. I kicked the ADC with software and got noisy numbers in the data register. So the ADC is up as well. Update should result in trigger out event for the timer. Trigger out event for the timer should fire up ADC. That does not happen.

 

It works for STM32F303.

What do I miss for STM32F429 ?

THX

Cheers

Detlef


@DetlefS wrote:

I started both TIM and ADC.


This could mean anything. Show your code. 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

Can you share your IOC file and user code? Otherwise this is a guessing game. This works in theory.

If you feel a post has answered your question, please click "Accept as Solution".

Voila. THX Detlef

You need to use HAL_TIM_Base_Start_IT which enables interrupt. 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

Don't know ...
I have several similiar applications that work fine, including one on the F407.
And none of them enables the timer interrupt (although the code is based on the SPL, not Cube/HAL).


But as a recommendation, I would configure and enable an ADC interrupt (EOC or EOS), and check if it fires.
In addition to step through the init code and confirm all the appropriate peripheral register config flags are set, and timer / ADC units are enabled.

waclawek.jan
Super User

Read out and check/post content of TIM and ADC registers.

JW

HAL_TIM_Base_Start_IT does not fix the issue.