cancel
Showing results for 
Search instead for 
Did you mean: 

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

dong2
Associate
Posted on April 01, 2016 at 06:19

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?

#hal-library
2 REPLIES 2
mark239955_stm1
Associate II
Posted on April 03, 2016 at 06:53

The best way to do this is to ignore ST's (abominable) HAL and go straight to the hardware, accessing the TIM and DMA registers directly.

dong2
Associate
Posted on April 04, 2016 at 17:28

Thank you for your answering, I have rewritten my code using standard peripheral libraries.