我利用stm32L4芯片内部DAC产生正弦波,再利用timer的PWM产生方波,可是利用示波器观察发现,两个波形不同步,开发库是HAL库,求解决方案,已经困扰我两个星期了。。。。我之前利用stm32F1的标准库产生的波形是同步的。。。部分代码如下:timer配置: void TIM1_Config(void) { TimHandle.Instance = TIM1; TimHandle.Init.Prescaler = uhPrescalerValue1; TimHandle.Init.Period = PERIOD_VALUE1; TimHandle.Init.ClockDivision = 0; TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP; TimHandle.Init.RepetitionCounter = 0; if (HAL_TIM_PWM_Init(&TimHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } sConfig.OCMode = TIM_OCMODE_PWM1; sConfig.OCPolarity = TIM_OCPOLARITY_HIGH; sConfig.OCFastMode = TIM_OCFAST_DISABLE; sConfig.OCNPolarity = TIM_OCNPOLARITY_HIGH; sConfig.OCNIdleState = TIM_OCNIDLESTATE_RESET; sConfig.OCIdleState = TIM_OCIDLESTATE_RESET; sConfig.Pulse = PULSE1_VALUE1; if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK) { /* Configuration Error */ Error_Handler(); } if (HAL_TIM_PWM_Start(&TimHandle, TIM_CHANNEL_1) != HAL_OK) { /* PWM Generation Error */ Error_Handler(); } } DAC时钟配置: void TIM6_Config(void) { TIM_MasterConfigTypeDef sMasterConfig; htim.Instance = TIM6; htim.Init.Period = PERIOD_VALUE6; htim.Init.Prescaler = uhPrescalerValue2; htim.Init.ClockDivision = 0; htim.Init.CounterMode = TIM_COUNTERMODE_UP; htim.Init.RepetitionCounter = 0; HAL_TIM_Base_Init(&htim); sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;//TIM_TRGO_ENABLE;// sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; HAL_TIMEx_MasterConfigSynchronization(&htim, &sMasterConfig); HAL_TIM_Base_Start(&htim); } |
问个关于STM32L4 SPI读数据,前3个字节永远是0
STM32L432 2个SPI同时使用的问题
STM32L476 ADC采集内部温度传感器电压值
STM32L431通过串口下载程序问题
ST的hal库有问题手头有STM32L4或STM32F7的帮忙测试DMA SD卡
STM32L476-Discovery开发板如何进行串口固件烧写
大家有用到STM32L433的CAN通信的吗?
STM32L4 FFT 自带arm_math.h编译不成功
想问一个关于STM32L475 flash的问题
谁有STM32L476的编程手册,传一个,感谢
评分
查看全部评分
评分
查看全部评分
评分
查看全部评分