我一直在尝试使用 HR tiM 生成“LL_ADC_REG_TRIG_EXT_HRTIM_TRG1”,以触发基于 STM32G474 的项目的 ADC 的双同步转换。
我使用 LL 驱动程序,据我了解,在 HRTIM 端启用触发器的代码应该是:
- // HRTIM Peripheral clock enable
- LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_HRTIM1);
- // HRTIM DLL (Delay-Locked-Loop) Calibration
- LL_HRTIM_ConfigDLLCalibration(HRTIM1, LL_HRTIM_DLLCALIBRATION_MODE_CONTINUOUS, LL_HRTIM_DLLCALIBRATION_RATE_3);
- while(LL_HRTIM_IsActiveFlag_DLLRDY(HRTIM1) == RESET){};
- // > HRTIM Master Configuration
- LL_HRTIM_TIM_SetPrescaler(HRTIM1, LL_HRTIM_TIMER_MASTER, LL_HRTIM_PRESCALERRATIO_MUL4);
- LL_HRTIM_TIM_SetPeriod(HRTIM1, LL_HRTIM_TIMER_MASTER, iInverter_PWM_Level);
- LL_HRTIM_TIM_SetRepetition(HRTIM1, LL_HRTIM_TIMER_MASTER, 0x00);
- // Time Base Settings:
- LL_HRTIM_TIM_SetCounterMode(HRTIM1, LL_HRTIM_TIMER_MASTER, LL_HRTIM_MODE_CONTINUOUS);
- // Timing Unit:
- LL_HRTIM_TIM_SetInterleavedMode(HRTIM1, LL_HRTIM_TIMER_MASTER, LL_HRTIM_INTERLEAVED_MODE_DISABLED);
- LL_HRTIM_TIM_DisableHalfMode(HRTIM1, LL_HRTIM_TIMER_MASTER);
- LL_HRTIM_TIM_DisableStartOnSync(HRTIM1, LL_HRTIM_TIMER_MASTER);
- LL_HRTIM_TIM_DisableResetOnSync(HRTIM1, LL_HRTIM_TIMER_MASTER);
- LL_HRTIM_TIM_SetDACTrig(HRTIM1, LL_HRTIM_TIMER_MASTER, LL_HRTIM_DACTRIG_NONE);
- LL_HRTIM_TIM_EnablePreload(HRTIM1, LL_HRTIM_TIMER_MASTER);
- LL_HRTIM_TIM_SetUpdateGating(HRTIM1, LL_HRTIM_TIMER_MASTER, LL_HRTIM_UPDATEGATING_INDEPENDENT);
- LL_HRTIM_TIM_SetBurstModeOption(HRTIM1, LL_HRTIM_TIMER_MASTER, LL_HRTIM_BURSTMODE_MAINTAINCLOCK);
- LL_HRTIM_TIM_SetUpdateTrig(HRTIM1, LL_HRTIM_TIMER_MASTER, LL_HRTIM_UPDATETRIG_NONE);
- // Wait for configuration applied
- while(LL_HRTIM_IsActiveFlag_DLLRDY(HRTIM1) == RESET){};
- // > HRTIM Trigger to START ADC Conversion
- LL_HRTIM_ConfigADCTrig(HRTIM1, LL_HRTIM_ADCTRIG_1, LL_HRTIM_ADCTRIG_UPDATE_MASTER, LL_HRTIM_ADCTRIG_SRC13_MPER);
- LL_HRTIM_SetADCPostScaler(HRTIM1, LL_HRTIM_ADCTRIG_1, 20);
而在 ADC 方面,它应该是:
- // Setup ADC1 as the master ADC:
- // - Receive the start of conversion from the HRTIM MASTER TRG1
- // - Setup the Scan sequence length, default is disabled.
- // - Disable sequencer discontinuity.
- // - Setup the Regular Conversion Mode in Single Conversion per Trigger
- ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_EXT_HRTIM_TRG1;
- ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
- ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
- ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
- ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED;
- ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_OVERWRITTEN;
- LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct);
- LL_ADC_SetGainCompensation(ADC1, 0);
- LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE);
现在代码正在运行,在通道 A、C、E、F 上生成中心对齐的 PWM 信号,并在双同步模式下获取 ADC 并成功进行 DMA 传输(与软件触发器一起使用时)……我真的不明白是什么我的配置中缺少。
我还分析了 B-G474E-DPOW1 应用程序演示代码(使用 HRTIM ADC 触发器),除了使用 HAL 之外,它看起来确实是一样的。也许我错过了某个地方的启用?
0
|
1个回答
|
|
|