Skip to main content
juvann
Associate III
January 24, 2023
Question

STM32WB55 acquire signal from GPIO using DMA and trigger TIM

I have a board P-NucleoWB55 and I'm trying to acquire a signal with external clock, very similar to uart, I tried with usart in slave mode without succcess, I tried with spi slave without success.

Now I'm trying to trigger a DMA transfer with a timer and clock source ETR.

I'm following this thread but the code use old api and I don't understand how start the timer.

I configured TIM2 Clock Source ETR2 and Counter Period, DMA TIM2_UP.

I read the AN4666 but I don't understand very well the example.

I tested this code:

 HAL_TIM_Base_Start(&htim2);
 HAL_DMA_Start_IT(&hdma_tim2_up, GPIOB->IDR, (uint32_t)buf, sizeof(buf));

I receive interrupt for timer but not for dma.

Thank you for suggestions

This topic has been closed for replies.

4 replies

RomainR.
ST Employee
January 25, 2023

Hello @juvann (Community Member)

Related to AN4666, in reception mode the external clock is received on a GPIO connected to a timer input channel (TIMx_CH) configured in Input Capture mode. The rising/falling edge events on external clock GPIO will trigger DMA request in peripheral to memory mode.

It seems your code just start a timer counter and then the DMA but after that ?

Have you downloaded the firmware expansion of the AN4666 and review the code for STM32L476 in reception mode ? I think it will help you to understand and port it to STM32WB55 using same peripherals.

https://www.st.com/en/embedded-software/x-cube-paral-com.html#overview

Regards,

Romain

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
juvann
juvannAuthor
Associate III
January 25, 2023

Hello @RomainR.​ ,

> but after that ?

After that, I expect an interrupt which notify me the transfer.

Input capture mode should be used when I want measure the time, rigth?

I just have to sampling the pin of GPIO.

Regards

juvann
juvannAuthor
Associate III
January 28, 2023

I have found a partial solution:

HAL_TIM_Base_Start(&htim2);
HAL_DMA_Start_IT(&hdma_tim2_up, (uint32_t)&GPIOC->IDR, (uint32_t)buf, 1);
SET_BIT(TIM2->DIER, TIM_DIER_UDE);

set size as sizeof(buf) is wrong is correct 1, so for every update 1 byte is transfered.

Bit TIM_DIER_UDE is not set in HAL.

juvann
juvannAuthor
Associate III
January 29, 2023

Also previous change doesn't work, I completly removed DMA and I use only interrupt on timer.

So in my HAL_TIM_PeriodElapsedCallback I read GPIO with (GPIOC->IDR & 1) and I compose byte with each bit.