完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
STM32g474 hrtim-half模式下 始终只能输出一个1脚,2脚没有输出 stm32f334 就没有这个问题static void MX_HRTIM1_Init(void)
{ /* USER CODE BEGIN HRTIM1_Init 0 */ /* USER CODE END HRTIM1_Init 0 */ HRTIM_TimeBaseCfgTypeDef pTimeBaseCfg = {0}; HRTIM_TimerCfgTypeDef pTimerCfg = {0}; HRTIM_CompareCfgTypeDef pCompareCfg = {0}; HRTIM_TimerCtlTypeDef pTimerCtl = {0}; HRTIM_DeadTimeCfgTypeDef pDeadTimeCfg = {0}; HRTIM_OutputCfgTypeDef pOutputCfg = {0}; /* USER CODE BEGIN HRTIM1_Init 1 */ /* USER CODE END HRTIM1_Init 1 */ hhrtim1.Instance = HRTIM1; hhrtim1.Init.HRTIMInterruptResquests = HRTIM_IT_NONE; hhrtim1.Init.SyncOptions = HRTIM_SYNCOPTION_NONE; if (HAL_HRTIM_Init( hhrtim1) != HAL_OK) { Error_Handler(); } if (HAL_HRTIM_DLLCalibrationStart( hhrtim1, HRTIM_CALIBRATIONRATE_3) != HAL_OK) { Error_Handler(); } if (HAL_HRTIM_PollForDLLCalibration( hhrtim1, 10) != HAL_OK) { Error_Handler(); } pTimeBaseCfg.Period = 0xFFDF; pTimeBaseCfg.RepetitionCounter = 0x00; pTimeBaseCfg.PrescalerRatio = HRTIM_PRESCALERRATIO_MUL32; pTimeBaseCfg.Mode = HRTIM_MODE_CONTINUOUS; if (HAL_HRTIM_TimeBaseConfig( hhrtim1, HRTIM_TIMERINDEX_MASTER, pTimeBaseCfg) != HAL_OK) { Error_Handler(); } pTimerCfg.InterruptRequests = HRTIM_MASTER_IT_NONE; pTimerCfg.DMARequests = HRTIM_MASTER_DMA_NONE; pTimerCfg.DMASrcAddress = 0x0000; pTimerCfg.DMADstAddress = 0x0000; pTimerCfg.DMASize = 0x1; pTimerCfg.HalfModeEnable = HRTIM_HALFMODE_DISABLED; pTimerCfg.InterleavedMode = HRTIM_INTERLEAVED_MODE_DISABLED; pTimerCfg.StartOnSync = HRTIM_SYNCSTART_DISABLED; pTimerCfg.ResetOnSync = HRTIM_SYNCRESET_DISABLED; pTimerCfg.DACSynchro = HRTIM_DACSYNC_NONE; pTimerCfg.PreloadEnable = HRTIM_PRELOAD_ENABLED; pTimerCfg.UpdateGating = HRTIM_UPDATEGATING_INDEPENDENT; pTimerCfg.BurstMode = HRTIM_TIMERBURSTMODE_MAINTAINCLOCK; pTimerCfg.RepetitionUpdate = HRTIM_UPDATEONREPETITION_ENABLED; pTimerCfg.ReSyncUpdate = HRTIM_TIMERESYNC_UPDATE_UNCONDITIONAL; if (HAL_HRTIM_WaveformTimerConfig( hhrtim1, HRTIM_TIMERINDEX_MASTER, pTimerCfg) != HAL_OK) { Error_Handler(); } pCompareCfg.CompareValue = 0xFFDF/4; if (HAL_HRTIM_WaveformCompareConfig( hhrtim1, HRTIM_TIMERINDEX_MASTER, HRTIM_COMPAREUNIT_1, pCompareCfg) != HAL_OK) { Error_Handler(); } pTimeBaseCfg.Period = 0xFFDF-2; if (HAL_HRTIM_TimeBaseConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_A, pTimeBaseCfg) != HAL_OK) { Error_Handler(); } pTimerCtl.UpDownMode = HRTIM_TIMERUPDOWNMODE_UP; pTimerCtl.TrigHalf = HRTIM_TIMERTRIGHALF_DISABLED; pTimerCtl.GreaterCMP1 = HRTIM_TIMERGTCMP1_EQUAL; pTimerCtl.DualChannelDacEnable = HRTIM_TIMER_DCDE_DISABLED; if (HAL_HRTIM_WaveformTimerControl( hhrtim1, HRTIM_TIMERINDEX_TIMER_A, pTimerCtl) != HAL_OK) { Error_Handler(); } pTimerCfg.InterruptRequests = HRTIM_TIM_IT_NONE; pTimerCfg.DMARequests = HRTIM_TIM_DMA_NONE; pTimerCfg.DMASrcAddress = 0x0000; pTimerCfg.DMADstAddress = 0x0000; pTimerCfg.DMASize = 0x1; pTimerCfg.InterleavedMode = HRTIM_INTERLEAVED_MODE_DUAL; pTimerCfg.PreloadEnable = HRTIM_PRELOAD_DISABLED; pTimerCfg.RepetitionUpdate = HRTIM_UPDATEONREPETITION_DISABLED; pTimerCfg.PushPull = HRTIM_TIMPUSHPULLMODE_DISABLED; pTimerCfg.FaultEnable = HRTIM_TIMFAULTENABLE_NONE; pTimerCfg.FaultLock = HRTIM_TIMFAULTLOCK_READWRITE; pTimerCfg.DeadTimeInsertion = HRTIM_TIMDEADTIMEINSERTION_DISABLED; pTimerCfg.DelayedProtectionMode = HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_DISABLED; pTimerCfg.UpdateTrigger = HRTIM_TIMUPDATETRIGGER_NONE; pTimerCfg.ResetTrigger = HRTIM_TIMRESETTRIGGER_MASTER_PER; pTimerCfg.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED; if (HAL_HRTIM_WaveformTimerConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_A, pTimerCfg) != HAL_OK) { Error_Handler(); } pTimerCfg.DMASrcAddress = 0x0000; pTimerCfg.DMADstAddress = 0x0000; pTimerCfg.DMASize = 0x1; pTimerCfg.PreloadEnable = HRTIM_PRELOAD_ENABLED; pTimerCfg.RepetitionUpdate = HRTIM_UPDATEONREPETITION_ENABLED; pTimerCfg.ResetTrigger = HRTIM_TIMRESETTRIGGER_MASTER_CMP1; pTimerCfg.ResetUpdate = HRTIM_TIMUPDATEONRESET_ENABLED; if (HAL_HRTIM_WaveformTimerConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_B, pTimerCfg) != HAL_OK) { Error_Handler(); } pCompareCfg.CompareValue = 0xFFDF; pCompareCfg.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR; pCompareCfg.AutoDelayedTimeout = 0x0000; if (HAL_HRTIM_WaveformCompareConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_2, pCompareCfg) != HAL_OK) { Error_Handler(); } pDeadTimeCfg.Prescaler = HRTIM_TIMDEADTIME_PRESCALERRATIO_DIV1; pDeadTimeCfg.RisingValue = 0x090; pDeadTimeCfg.RisingSign = HRTIM_TIMDEADTIME_RISINGSIGN_NEGATIVE; pDeadTimeCfg.RisingLock = HRTIM_TIMDEADTIME_RISINGLOCK_WRITE; pDeadTimeCfg.RisingSignLock = HRTIM_TIMDEADTIME_RISINGSIGNLOCK_WRITE; pDeadTimeCfg.FallingValue = 0x090; pDeadTimeCfg.FallingSign = HRTIM_TIMDEADTIME_FALLINGSIGN_NEGATIVE; pDeadTimeCfg.FallingLock = HRTIM_TIMDEADTIME_FALLINGLOCK_WRITE; pDeadTimeCfg.FallingSignLock = HRTIM_TIMDEADTIME_FALLINGSIGNLOCK_WRITE; if (HAL_HRTIM_DeadTimeConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_A, pDeadTimeCfg) != HAL_OK) { Error_Handler(); } pOutputCfg.Polarity = HRTIM_OUTPUTPOLARITY_HIGH; pOutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1; pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_MASTERPER; pOutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE; pOutputCfg.IdleLevel = HRTIM_OUTPUTIDLELEVEL_INACTIVE; pOutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE; pOutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED; pOutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR; if (HAL_HRTIM_WaveformOutputConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA1, pOutputCfg) != HAL_OK) { Error_Handler(); } pOutputCfg.SetSource = HRTIM_OUTPUTSET_TIMPER; pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1; if (HAL_HRTIM_WaveformOutputConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_B, HRTIM_OUTPUT_TB1, pOutputCfg) != HAL_OK) { Error_Handler(); } pOutputCfg.SetSource = HRTIM_OUTPUTSET_NONE; pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE; if (HAL_HRTIM_WaveformOutputConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA2, pOutputCfg) != HAL_OK) { Error_Handler(); } if (HAL_HRTIM_WaveformOutputConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_B, HRTIM_OUTPUT_TB2, pOutputCfg) != HAL_OK) { Error_Handler(); } if (HAL_HRTIM_TimeBaseConfig( hhrtim1, HRTIM_TIMERINDEX_TIMER_B, pTimeBaseCfg) != HAL_OK) { Error_Handler(); } if (HAL_HRTIM_WaveformTimerControl( hhrtim1, HRTIM_TIMERINDEX_TIMER_B, pTimerCtl) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN HRTIM1_Init 2 */ /* USER CODE END HRTIM1_Init 2 */ HAL_HRTIM_MspPostInit( hhrtim1); } |
|
相关推荐
1个回答
|
|
1. 配置错误:请确保已正确配置HRTIM和HALF模式,包括时间基准、定时器配置、比较器配置和定时器控制。查阅STM32G4xx Reference Manual,确认配置是否正确。 2. 针脚选择:请检查是否正确选择了要用于输出的GPIO脚。根据规格书中的引脚定义和功能分配表,确认正确选择了用于输出的脚。 3. HAL库版本:确保使用的是最新的STM32Cube HAL库,并尝试更新到最新版本,以确保解决了任何已知的问题或错误。 4. 调试输出:使用调试工具(如Oscilloscope)监测引脚输出以及HAL库的调用过程,验证是否有任何错误或异常发生。 5. 配置冲突:检查其他相关功能的配置。确保没有其他设置或配置与HRTIM和HALF模式冲突。 |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1752 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1611 浏览 1 评论
1052 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
721 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1666 浏览 2 评论
1926浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
712浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
561浏览 3评论
584浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
544浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 03:26 , Processed in 0.739016 second(s), Total 83, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号