2018-09-17 11:06 AM
Hi everyone!
After AVR mcus STM32 with Cube and HAL is like an oasis in the desert! But after many experiments, researches and sleepless nights I know the situation isn't so great as I thought.
I have few boards with 100, 103, 407 and other series.
I'm generating new project using cube for STM32F103C8T6 mcu. Selected options are: 72MHz freq, TIM1 in PWM+PWMN mode on first channel, DMA transmits pulse durations from array to channel, empty main loop. Working in KEIL uVision 5, HAL drivers.
So here we have some miracles:
PWM and DMA STOPS AT ALL if pulse was written zero value.
BUT it's working fine without DMA!
uint16_t Values[3] = {0, 1000, 2000}; //works only with UP counting timer
uint16_t Values2[3] = {1, 1000, 2000}; //also works on center-aligned UP-DOWN counting timer
//... Initialization code ARR = 4999
HAL_TIM_PWM_START_DMA(&htim1, TIM_CHANNEL_1, (uint32_t*)&Values, sizeof(Values) );
//working
HAL_TIMEx_PWMN_START_DMA(&htim1, TIM_CHANNEL_1, (uint32_t*)&Values, sizeof(Values) );
//doesn't working
I dug all documentatin and forums i found and have found no answer. Somebody answered that we need to use WORD size variables, while somebody discovered that DMA copies first (lower) part of word WITH value and by second transaction copies ZEROES (second, higher part). Where is the truth?
Maybe somebody have some appnotes describing HOW TO work with this HAL step by step (NOT the cube help document that desribes only function itself) i.e. how to START timers, conversions, transmissions PROPERLY. Yes, i'm talking about HAL, not about datasheets with tonns of registers only.
Thanks a lot!