DMA for controlling GPIO output is not working on STM32H7 devices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-02 12:24 AM
I am trying to use DMA to control GPIO port E output.
Below is configuration of CubeMX
In Cortex-M4 context of dual core , DMA is successfully working to toggle GPIO Port E output .
But In Cortex-M7 context of dual core , although error message, DMA is not working.
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* USER CODE BEGIN Boot_Mode_Sequence_0 */
int32_t timeout;
/* USER CODE END Boot_Mode_Sequence_0 */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* USER CODE BEGIN Boot_Mode_Sequence_1 */
/* Wait until CPU2 boots and enters in stop mode or timeout*/
timeout = 0xFFFF;
// while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));
// if ( timeout < 0 )
// {
// Error_Handler();
// }
/* USER CODE END Boot_Mode_Sequence_1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN Boot_Mode_Sequence_2 */
/* When system initialization is finished, Cortex-M7 will release Cortex-M4 by means of
HSEM notification */
/*HW semaphore Clock enable*/
//__HAL_RCC_HSEM_CLK_ENABLE();
////*Take HSEM */
//HAL_HSEM_FastTake(HSEM_ID_0);
////*Release HSEM in order to notify the CPU2(CM4)*/
//HAL_HSEM_Release(HSEM_ID_0,0);
////* wait until CPU2 wakes up from stop mode */
//timeout = 0xFFFF;
//while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0));
//if ( timeout < 0 )
//{
//Error_Handler();
//}
/* USER CODE END Boot_Mode_Sequence_2 */
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */
uint32_t _gTriOutState[2] = {0x0000FFFF,0xFFFF0000 };
__HAL_TIM_ENABLE_DMA(&htim1, TIM_DMA_CC1);
//__HAL_TIM_ENABLE_DMA(&htim1, TIM_DMA_CC2);
HAL_TIM_Base_Start_IT(&htim1);
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
HAL_Delay(15);
if (HAL_DMA_Start(&hdma_tim1_ch1, (uint32_t)&_gTriOutState, (uint32_t)&(GPIOE->BSRR),2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
- Labels:
-
DMA
-
GPIO-EXTI
-
STM32H7 series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-02 12:59 AM
Hello @hryu.1​ and welcome to the Community :)
Please update the line MX_DMA_Init(); before MX_GPIO_Init().
This is a known issue (when using CubeMx v6.3.0) with the DMA initialization which should be before any other peripheral initialization .
This limitation will be fixed in the next release of CubeMx.
Hope this solve your issue.
When your issue is solved, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-02 1:20 AM
as you suggested, I did it. But it is not working in Cortex-M7 .
is it impossible technically to use DMA1, DMA2 in Cortex-M7?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-02 1:35 AM
Do I use MDMA instead of DMA1,DMA2?
If i have to use this,Please, let me know how to use it?
STM32H745xI/G datasheet ​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-02 1:43 AM
The problem is maybe related two things: memory layout on STM32H7 and internal data cache (D-Cache) of the Cortex-M7 core.
Please have a look at this FAQ: DMA is not working on STM32H7 devices.
I'll be waiting for your progress=)
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-04 5:04 AM
Hi @hryu.1​ ,
Were you able to resolve the issue?
Please share your progress or resolution here, so it may be helpful for members of the community.
Thanks
Imen
Thanks
Imen
