2022-04-14 08:50 AM
Hi everyone,
I am using the NUCLEO-G474RE development board with STM32G474RE MCU
The ioc file is attached, and this is main function:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
/* System interrupt init*/
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
/* SysTick_IRQn interrupt configuration */
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),15, 0));
/** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral
*/
LL_PWR_DisableUCPDDeadBattery();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_DMA_Init();
MX_GPIO_Init();
MX_TIM6_Init();
MX_DAC1_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
uint16_t Data[2] = {0xFFF, 0x800};
LL_DAC_Enable(DAC1, LL_DAC_CHANNEL_2);
while (LL_DAC_IsActiveFlag_DAC2RDY(DAC1) == 0);
LL_DMA_SetPeriphAddress(DMA1, LL_DMA_CHANNEL_3, (uint32_t) &DAC1->DHR12R2);
LL_DMA_SetMemoryAddress(DMA1, LL_DMA_CHANNEL_3, (uint32_t) &Data);
LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_3, 2);
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_3);
LL_TIM_EnableDMAReq_UPDATE(TIM6);
LL_TIM_EnableCounter(TIM6);
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
I use TIM6 to generate a periodic DMA request and use it to send waveform data to "DAC_DHRx", but the DMA generates a transfer error (DMA TEIF flag is 1).
When I reset the DMA direction to "Peripheral to Memory" in CubeMX, DAC_DHRx can be sent to memory.
Besides that, I have ported this program to STM32L476G-DISCO and it also works fine.
What setting am I missing?
Solved! Go to Solution.
2022-04-14 07:02 PM
I solved the problem, I found the following information in the reference manual 12.4.6:
AHB peripherals not supporting byte/half-word write transfers, so I change the data width to word, and it works fine.
2022-04-14 04:10 PM
Is Data in a DMA-accessible location? Print out the DMA stream register information.
2022-04-14 05:46 PM
Hi TDK,
Thank you for your reply, and here is my DMA setup:
It should be the DMA accessible location
2022-04-14 07:02 PM
I solved the problem, I found the following information in the reference manual 12.4.6:
AHB peripherals not supporting byte/half-word write transfers, so I change the data width to word, and it works fine.