2019-12-30 08:50 AM
Hi All,
Looking at the STM32H7 Ref manual it seems the DMAMUX would allow for a DMA channel to be synchronized with an external event on the EXTI0 input.
I would like to use this capability to trigger an SPI transmission to an ADC (since this would allow me to avoid time consuming tasks in the ISR routines )
I figured I would be able to configure the SPI2 TX in DMA mode and enable the DMA request synchronization settings so I have the following configuration.
SPI2 TX is assigned to DMA1 Stream 0. and the DMA Request synchronization settings are setup for
Enable Synchronization
Synchronization signal EXTI0
SignalPolarity: Synchronize on falling edge
Request Number: 1
The SPI initialization is as follows
hdma_spi2_tx.Instance = DMA1_Stream0;
hdma_spi2_tx.Init.Request = DMA_REQUEST_SPI2_TX;
hdma_spi2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_spi2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_spi2_tx.Init.MemInc = DMA_MINC_DISABLE;
hdma_spi2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_spi2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_spi2_tx.Init.Mode = DMA_CIRCULAR; //DMA_NORMAL;
hdma_spi2_tx.Init.Priority = DMA_PRIORITY_MEDIUM;
hdma_spi2_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_spi2_tx) != HAL_OK)
{
Error_Handler();
}
pSyncConfig.SyncSignalID = HAL_DMAMUX1_SYNC_EXTI0;
pSyncConfig.SyncPolarity = HAL_DMAMUX_SYNC_FALLING;
pSyncConfig.SyncEnable = ENABLE;
pSyncConfig.EventEnable = DISABLE;
pSyncConfig.RequestNumber = 1;
if (HAL_DMAEx_ConfigMuxSync(&hdma_spi2_tx, &pSyncConfig) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(hspi,hdmatx,hdma_spi2_tx);
The EXTI input is configured as follows
GPIO_InitStruct.Pin = SPI2_EXTI_SYNC_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLDOWN; //GPIO_NOPULL;
HAL_GPIO_Init(SPI2_EXTI_SYNC_GPIO_Port, &GPIO_InitStruct);
The EXTI input is PA0 and it is driven via a PWM signal from the High resolution timer output pin connected to PA0.
I have verified that I am getting a pulse every 1 us on the EXTI input - however the SPI DMA TX is not being triggered.
Any thoughts on if this is an appropriate way to achieve the desired outcome or am I missing something?
Thanks
Jay
2023-02-15 11:22 AM
Would it be possible your share you basic code for DMAMUX SPI transfer. I am having issues using DMAMUX1 to work with LPTIM1 output to do an SP transfer.