2017-12-29 07:50 AM
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?
ThanksDiego
Milan,Italy
2017-12-29 08:05 AM
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)
2017-12-31 12:05 PM
Hi Clive,thanks for help
i did some small progress and i'm a little most aware about what is happening inside the registerwhat 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 start2)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 registerTrying 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 theHAL_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 year2018-01-01 08:02 AM
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
2018-01-05 01:59 AM
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 calledHAL_TIM_OC_Start_IT(&htim1, TIM_CHANNEL_1);
HAL_TIM_IC_Start_IT (&htim1, 1);and everything works,thanks for help Clive One
Diego