2.0 KiB
2.0 KiB
B-G474E-DPOW1 DCDC Code Map
Runtime knobs
The live configuration object is:
g_dcdc_config
Edit it in Keil Watch while the target is running.
Useful fields:
g_dcdc_config.mode
g_dcdc_config.pwm.frequency_hz
g_dcdc_config.pwm.test_duty_permille
g_dcdc_config.pwm.deadtime_enable
g_dcdc_config.pwm.deadtime_rising_ticks
g_dcdc_config.pwm.deadtime_falling_ticks
g_dcdc_config.limits.target_vout_mv
g_dcdc_config.limits.current_limit_ma
Modes:
0 = DCDC_MODE_MONITOR
1 = DCDC_MODE_PWM_TEST
2 = DCDC_MODE_CLOSED_LOOP
Startup path
main.c:
Board_Init()starts clocks, SysTick, GPIO basics.Retarget_Init()enablesprintf()throughUSART3.DCDC_Init()prepares ADC and HRTIM Timer C.DCDC_Service1ms()runs every 1 ms and applies live runtime edits.
HRTIM PWM path
dcdc.c:
hrtim1_timer_c_init()configures HRTIM1 Timer C.DCDC_StartPwmTest()starts open-loop analyzer PWM.hrtim1_apply_pwm_config()applies live frequency and dead-time edits.hrtim1_set_duty()updatesCMP1, which sets the PB12/PB13 split point.
Current complementary test routing:
PB12 / CHC1: set at period, reset at CMP1
PB13 / CHC2: set at CMP1, reset at period
Dead-time is enabled by:
timer->OUTxR |= HRTIM_OUTR_DTEN;
ADC path
DCDC_ReadMeasurements() reads:
PA1 / ADC1_IN2 = VIN
PA2 / ADC1_IN3 = input current average
PA3 / ADC1_IN4 = VOUT
Raw ADC values are converted through:
adc_raw_to_mv()
sense_mv_to_voltage_mv()
sense_mv_to_current_ma()
Safety path
The closed-loop mode checks:
g_dcdc_config.limits.min_vin_mv
g_dcdc_config.limits.max_vout_mv
g_dcdc_config.limits.hard_current_ma
If a limit trips, latch_fault() disables HRTIM outputs, clears duty, opens
the USB-PD/VIN switch, and moves the state to DCDC_STATE_FAULT.
Current safe workflow
- Keep
g_dcdc_config.mode = 1. - Tune
g_dcdc_config.pwm.deadtime_*_ticks. - Verify PB12/PB13 on the logic analyzer.
- Only after clean waveforms, move toward closed-loop testing.