cancel
Showing results for 
Search instead for 
Did you mean: 

F072 Nucleo TIM2/DMA/Input capture issues

o2
Associate II
Posted on July 17, 2016 at 08:43

I am trying to work with STM32F072 input capture using TIM2 and DMA transfers.

There is an issue in CubeMX which make it always change the alignment to BYTE, I always have to change it back to WORD, really annoying... I also noticed that once I configure DMA memory address alignment to WORD, hardware issues pop up, here is the code that inits DMA:

hdma_tim2_ch1.Instance = DMA1_Channel5;
hdma_tim2_ch1.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_tim2_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim2_ch1.Init.MemInc = DMA_MINC_ENABLE;
hdma_tim2_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_tim2_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_tim2_ch1.Init.Mode = DMA_CIRCULAR;
hdma_tim2_ch1.Init.Priority = DMA_PRIORITY_HIGH;

When the code enters HAL_TIM_IC_CaptureCallback in main.c, if the memory alignment is set to DMA_MDATAALIGN_WORD, the code directly goes to HardFault_Handler inside stm32f0xx_it.c when exectuing __HAL_TIM_SET_COUNTER(htim, 0); indicating there is an issue with htim address. When memory alignment is configured to either HALFWORD or BYTE, htim address is correct, but really useless in my case. I traced the code, when it arrives to TIM_DMACaptureCplt inside stm32f0xx_hal_tim.c, it seems that this line is responsible for getting htim address:

TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;

which results in the wrong address in case memory alignment was set to DMA_MDATAALIGN_WORD. I attched the files inside Src directory in addition to CubeMX file. Create a new directory , copy its path and place CubeMX file inside this directory and edit the paths inside ioc file to become the path of the directory you created to be able to open ioc file correctly. finally, why do I have to reset TIM2 everytime I exit

HAL_TIM_IC_CaptureCallback

to get correct results? CubeMX version: 4.1 F0Cube version: 1.6
5 REPLIES 5
o2
Associate II
Posted on July 20, 2016 at 19:26

can any body help?

Posted on July 20, 2016 at 19:39

can any body help?

 

I don't think there are any rules about who can and can't help, but there aren't many helpful Pro Cubists here.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on July 20, 2016 at 19:49

> not many cubists here

Maybe more in https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx ?

JW
o2
Associate II
Posted on July 21, 2016 at 00:58

Where should I go then!?

suggest another place plz.

Posted on July 21, 2016 at 02:09

It is a bit like asking vegetarians where to get a good hamburger....

As Jan suggests here the [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx]Software and Firmware page has a higher level of Cube related posts, that may or may not result in more responses, forums tend to have a chronic imbalance of those with issues, and those with solutions.

More generally I'd recommend tool vendor support sites, and search engines to find people with a common cause.

You might also get responses here too, the population is transient, but if you have to bump a thread it indicates you haven't found an audience.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..