cancel
Showing results for 
Search instead for 
Did you mean: 

How to read GPIO data [8-bit of Port D] uisng DMA1 of STM32F429 MCU ?

Rajesh1
Associate II

We have configured TIM2 Channel 1 to capture rising edge on PA0 pin.

We have enabled DMA1 Stream5 to read data on Port D and copy to local array.

The callback function for DMA1 is not triggered.

Please let us know, if we are missing any configuration.

Note: We are using STM32CubeIDE version 1.5.1 for our project.

Regards,

Rajesh K.

10 REPLIES 10

Try using DMA2 and a TIM on APB2

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

HI Tesla,

We have tried with TIM8 using DMA2 Stream4.

Still no progress.

Regards,

Rajesh K.

What do you mean by "no progress"?

Read out and check/post content of TIM and DMA (and perhaps GPIO) registers' content.

JW

Rajesh1
Associate II

Hi JW,

We have initialized timer and registered callback for DMA with below calls.

 HAL_TIM_Base_Start_IT(&htim8);

 HAL_TIM_IC_Start_IT(&htim8, TIM_CHANNEL_3);

 HAL_DMA_RegisterCallback(&hdma_tim8_ch3, HAL_DMA_XFER_CPLT_CB_ID, Transfer_Complete);

HAL_DMA_Start_IT(&hdma_tim8_ch3, GPIOD->IDR, (uint32_t)DMA_Data_Ptr, 1);

We have initiated DMA transfer using below call in input capture callback function

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)

{

Input_Capture++;

}

The DMA callback function is not invoked. No data received in *DMA_Data_Ptr.

static void Transfer_Complete(DMA_HandleTypeDef *DmaHandle)

{

printf("/n/rDMA Transfer Complete . . .");

}

Regards,

Rajesh K.

Hi Rajesh,

I don't use Cube.

> Input_Capture++;

How does that initiate DMA transfer?

Read out and check/post content of TIM and DMA (and perhaps GPIO) registers' content.

 JW

Rajesh1
Associate II

HI JW,

DMA transfer is initiated by below call at initialization.

HAL_DMA_Start_IT(&hdma_tim8_ch3, GPIOD->IDR, (uint32_t)DMA_Data_Ptr, 1);

DMA data is processed in main() function.

main ()

{

.

.

.

if (Input_Capture)

printf("DMA data : %d",DMA_Data_Ptr);

}

DMA transfer is initiated after input captured using TIM8 Channel3. The transferred data is stored in DMA_Data_Ptr.

In main() function DMA_Data_Ptr data is sent to serial port.

Regards,

Rajesh K.

You'll need the address of the IDR for starters, and might need the read to be 32-bit wide. If transfers don't occur check for error status on the DMA side.​

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

> address of the IDR

i.e. &GPIOD->IDR (maybe suitably cast, if the functions asks for it).

Nice catch.

Similarly with DMA_Data_Ptr, as it doesn't appear to be an array.

JW

Rajesh1
Associate II

HI JW,

We have initialized TIM8 Channel 3 in STM32Cube IDE. Please find the captued intialization below.

DMA transfer is initiated in Timer callback function as below.

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)

{

 if (htim->Instance == TIM8)

 {

  Status = HAL_DMA_Start_IT(&hdma_tim8_ch3, (uint32_t)&GPIOD->IDR, (uint32_t)&DMA_Data[Data_Cnt++], 1);

  Timer_Cnt = 0;

 }

}

While debugging Status of DMA transfer is showing as DMA busy. What could be the reasons for DMA busy status?

Can you suggest the initialization sequence to use DMA

Regards,

Rajesh K.