cancel
Showing results for 
Search instead for 
Did you mean: 

Can't trigger ADC1 from TIM1 event

Diego Colombo
Associate III
Posted on December 29, 2017 at 16:50

Help needed,please.

I'm using CubeMx and STM32Workbench,STM32F410 on a custom board

I can't trigger ADC1 from TIM1,

TIM1 does generatean interrupt on compare channel 1,and i can see it,because i call a pin toggle in the interrupt routine and i have it on the oscilloscope.

This event should trigger the start of the ADC1,setting at 0b100 the MMS bits in TIM1->CR2 register,and in CubeMx the ADC External Trigger Conversion Source is associated to this event.

Anyway no ADC conversion starts,i set a trap on the ADC->DR register if different from zero,but no way.

Please,do you have some hints to check where the error could be?Is there any register that i can check or force to see the ADC working once,at least?

Thanks

Diego

Milan,Italy

4 REPLIES 4
Posted on December 29, 2017 at 17:05

I wouldn't trap or poke at the ADC registers from the debugger.

Does the ADC work in normal, manual triggered, application?

Does the DMA controller indicate any they of fault/error?

Check the EXTSEL settings in the ADC (0000b -> TIM1 CC1)

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on December 31, 2017 at 20:05

Hi Clive,thanks for help

i did some small progress and i'm a little most aware about what is happening inside the register

what i was able to do is to trigger a single ADC start,furthermore i set the ADc in DMA on 12 channels,and i can read correct values in the destination array.

Anyway it happens only once.To have it reapeated i have to restart the TIM1 in this way:

if(CHECK_CONVERSION_DONE)

{

   CLEAR_CONVERSION_DONE;

   HAL_TIM_IC_Start_IT (&htim1, 1);

}

Answering to your questions,by now

1)Yes,if i set by debugger the software start bit the ADC does start 

2)No DMA controller error

3)

 EXTSEL settings were correct

I dont'know why the event is generated only once.

The other odd thing is that i can change or even see the TIM1->EGR register

Trying to investigate wich is the reason why i have to restart TIM 1 i explored the HAL function,

even more odd,at least to me, is that if i change my code including the 3 function in the

HAL_TIM_IC_Start_IT body, it does not work

if(CHECK_CONVERSION_DONE)

{

      CLEAR_CONVERSION_DONE;

      __HAL_TIM_ENABLE_IT(&htim1, TIM_IT_CC1);

      TIM_CCxChannelCmd(&htim1, 1, TIM_CCx_ENABLE);

      __HAL_TIM_ENABLE(&htim1);

}

Next move is to sold a wire on the CH1 output pin,and i expect that the scope will show only one PWM event

Thanks again,i hope i don't have added further confusion

Happy new year
Posted on January 01, 2018 at 16:02

The last part does not work only because of my error:

it has to be correct in

TIM_CCxChannelCmd(htim1.Instance, 1, TIM_CCx_ENABLE);

and this row is enough to make it work,but of corse it is a workaround to a problem that i still can't focus.

This function simply clears and resets the CC1E bit in TIM1_CCER register.

I still dont know how it is necessary

 

Posted on January 05, 2018 at 09:59

Solved....I changed some incorrect setting in CubeMx

I started from zero using the channel in PWM Mode 1,so to check on pin that the compare was as expected.

then i simply called

HAL_TIM_OC_Start_IT(&htim1, TIM_CHANNEL_1);

HAL_TIM_IC_Start_IT (&htim1, 1);

and everything works,thanks for help Clive One

Diego