2016-07-16 11:43 PM
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.62016-07-20 10:26 AM
2016-07-20 10:39 AM
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.
2016-07-20 10:49 AM
> not many cubists here
Maybe more in https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx ? JW2016-07-20 03:58 PM
Where should I go then!?
suggest another place plz.2016-07-20 05:09 PM
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.