AnsweredAssumed Answered

How to transmit data from/to 2 channels of a single timer with DMA?

Question asked by dong.yang.002 on Apr 1, 2016
Latest reply on Apr 4, 2016 by dong.yang.002
Hello,
I'm trying to drive DS12B80(One-wire interface)using F030. Thus I initiated a PWM output channel 4 and a input capture channel 1 of TIM3. And the DMAs are started with:

HAL_TIM_IC_Start_DMA(htim,TIM_CHANNEL_1,(uint32_t *)rxdata,90);
HAL_TIM_PWM_Start_DMA(htim,TIM_CHANNEL_4,(uint32_t *)txdata,102);

I want to generate a PWM wave to drive DS18B20 as a master and receive its response by the input capture channel. This context doesn't work because while a DMA of a timer is running, htim->state is set to BUSY.

So I make some changes here:
HAL_TIM_IC_Start_DMA(htim,TIM_CHANNEL_1,(uint32_t *)rxdata,90);
htim->State=HAL_TIM_STATE_READY;
 HAL_TIM_PWM_Start_DMA(htim,TIM_CHANNEL_4,(uint32_t *)txdata,102);

this code DID work, but this mixing style dose not look comfortable.So I wonder if the code is acceptable?Is there any better way to realise the function?

Outcomes