DMA to DAC transfer in normal mode too slow
Hi,
I'm using STM32G431RB on the NUCLEO-G431RB developement board.
I want to generate a signal from an array each time an external trigger is received.
The signal is sampled with the TIMER6 trigger, which is rised every 1us. (MCU clock is 170MHz, TIMER6 PSC is 0 and ARR is 170-1).
TIMER6 configuration
The DMA is set to normal mode (because I want to generate a signal only when the trigger comes, and not continuously)
DAC DMA configuration
The DAC is configured like this:
DAC configuration
I'm calling the HAL_DAC_Start_DMA function each time the external trigger rises, but, even if the trigger is repeated each 1ms, the signal is generated each 2ms. The minimum interval between a signal generation and another one is 2ms and basically I need to reduce it as much as possible.
Signal
Here the trigger is faster than 2ms but the signal is generated each 2ms
The code:
/* Private variables ---------------------------------------------------------*/
DAC_HandleTypeDef hdac1;
DMA_HandleTypeDef hdma_dac1_ch1;
TIM_HandleTypeDef htim6;
/* USER CODE BEGIN PV */
uint8_t dac_flag = 0;
uint32_t data[41] = {2048, 2148, 2248, 2348, 2448, 2548, 2648, 2748, 2848, 2948, 3048, 2948, 2848, 2748, 2648, 2548, 2448, 2348, 2248, 2148, 2048, 1948, 1848, 1748, 1648, 1548, 1448, 1348, 1248, 1148, 1048, 1148, 1248, 1348, 1448, 1548, 1648, 1748, 1848, 1948, 2048}; //Signal lookup table
/* USER CODE END PV */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_DAC1_Init();
MX_TIM6_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start(&htim6);
//Initial value
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 2048);
HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
{
if(GPIO_Pin == STAGE_TRIG_Pin)
{
dac_flag = 1;
}
}
