完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
实验平台:Nucleo-STM32G474RE开发板
验证功能:希望利用DMA把数据传到DAC3的DAC_DHR12R1寄存器产生波形,再通过运放的跟随输出到外部管脚 问题描述:DMA没有更新DAC3的DHR12R1寄存器数据,进而无波形产生 DAC3配置: static void MX_DAC3_Init(void) { /* USER CODE BEGIN DAC3_Init 0 */ /* USER CODE END DAC3_Init 0 */ DAC_ChannelConfTypeDef sConfig = {0}; /* USER CODE BEGIN DAC3_Init 1 */ /* USER CODE END DAC3_Init 1 */ /** DAC Initialization */ hdac3.Instance = DAC3; if (HAL_DAC_Init( hdac3) != HAL_OK) { Error_Handler(); } /** DAC channel OUT1 config */ sConfig.DAC_HighFrequency = DAC_HIGH_FREQUENCY_INTERFACE_MODE_AUTOMATIC; sConfig.DAC_DMADoubleDataMode = DISABLE; sConfig.DAC_SignedFormat = DISABLE; sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; sConfig.DAC_Trigger = DAC_TRIGGER_T2_TRGO; sConfig.DAC_Trigger2 = DAC_TRIGGER_NONE; sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE; sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_ENABLE; sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; if (HAL_DAC_ConfigChannel( hdac3, sConfig, DAC_CHANNEL_1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN DAC3_Init 2 */ /* USER CODE END DAC3_Init 2 */ } OPAMP1配置 static void MX_OPAMP1_Init(void) { /* USER CODE BEGIN OPAMP1_Init 0 */ /* USER CODE END OPAMP1_Init 0 */ /* USER CODE BEGIN OPAMP1_Init 1 */ /* USER CODE END OPAMP1_Init 1 */ hopamp1.Instance = OPAMP1; hopamp1.Init.PowerMode = OPAMP_POWERMODE_NORMAL; hopamp1.Init.Mode = OPAMP_FOLLOWER_MODE; hopamp1.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_DAC; hopamp1.Init.InternalOutput = DISABLE; hopamp1.Init.TimerControlledMuxmode = OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE; hopamp1.Init.UserTrimming = OPAMP_TRIMMING_FACTORY; if (HAL_OPAMP_Init( hopamp1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN OPAMP1_Init 2 */ /* USER CODE END OPAMP1_Init 2 */ } TIMER2配置: static void MX_TIM2_Init(void) { /* USER CODE BEGIN TIM2_Init 0 */ /* USER CODE END TIM2_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; /* USER CODE BEGIN TIM2_Init 1 */ /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; htim2.Init.Prescaler = 0; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 169; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init( htim2) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource( htim2, sClockSourceConfig) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization( htim2, sMasterConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM2_Init 2 */ /* USER CODE END TIM2_Init 2 */ } DMA配置: static void MX_DMA_Init(void) { /* DMA controller clock enable */ __HAL_RCC_DMAMUX1_CLK_ENABLE(); __HAL_RCC_DMA1_CLK_ENABLE(); /* DMA interrupt init */ /* DMA1_Channel1_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn); } 主程序: /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_DAC3_Init(); MX_OPAMP1_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ for (i=0;i |
|
相关推荐
1个回答
|
|
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
这句改成 DAC_OUTPUTBUFFER_ENABLE 试试 |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1659 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1571 浏览 1 评论
998 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
695 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1617 浏览 2 评论
1888浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
668浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
531浏览 3评论
549浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
520浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 03:22 , Processed in 0.704006 second(s), Total 48, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号