2021-02-24 08:53 PM
I want to read from GPIOB in regular intervals into the RAM. After 8 hours of reading blog posts, examples and trying different things I had no success. I am using STM32Cube to generate code and I am using following code to initiate transfer. So far among many other things I tried using TMR4's tmr4_up event to trigger DMA1 Channel 7, and used following call to initiate DMA transfer.
HAL_DMA_Start(&hdma_tim4_up, &GPIOB->IDR, (uint32_t *)buffer1, sizeof(buffer1));
As soon as DMA channel is enabled execution halts and MCU gets stuck on following line;
__HAL_DMA_ENABLE(hdma);
Using same method to read from UART1 works fine when I setup DMA channel for UART with STM32Cube.
Any help will be appreciated.
Here is DMA initialization code
__HAL_RCC_TIM4_CLK_ENABLE();
/* TIM4 DMA Init */
/* TIM4_UP Init */
hdma_tim4_up.Instance = DMA1_Channel7;
hdma_tim4_up.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_tim4_up.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim4_up.Init.MemInc = DMA_MINC_ENABLE;
hdma_tim4_up.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_tim4_up.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_tim4_up.Init.Mode = DMA_NORMAL;
hdma_tim4_up.Init.Priority = DMA_PRIORITY_LOW;
if (HAL_DMA_Init(&hdma_tim4_up) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(htim_base,hdma[TIM_DMA_ID_UPDATE],hdma_tim4_up);
2021-02-24 11:57 PM
I don't use Cube, but
> HAL_DMA_Start(&hdma_tim4_up, &GPIOB->IDR, (uint32_t *)buffer1, sizeof(buffer1));
as Size probably need number of transfers, so if you transfer halfwords, then sizeof(buffer1)/2
JW