 |
EPC9143 300 W 16th Brick DC/DC Module Reference Design
|
|
44 #include "config/hal.h"
45 #include "app_power_control.h"
46 #include "./devices/dev_buck_converter.h"
48 #include "./drivers/v_loop.h"
49 #include "./drivers/v_loop_agc.h"
51 #include "fault_handler/app_fault_monitor.h"
68 volatile uint16_t retval = 1;
69 volatile uint16_t _i = 0;
70 volatile bool adc_trigger_mode=
false;
307 volatile uint16_t retval = 1;
422 volatile uint16_t retval=1;
446 ADCON4Hbits.C1CHS = 1;
#define BUCK_VOUT_NORM_FACTOR
VOUT normalization factor scaled in Q15.
volatile uint16_t gpio_high
GPIO port pin-number of PWMxH of the selected PWM generator.
#define BUCK_ISNS2_ADCBUF
ADC input buffer of this ADC channel.
volatile bool swap_source
Bit 13: when set, AltSource is used as data input to controller.
#define BUCK_PWM2_GPIO_INSTANCE
Number indicating device port, where 0=Port RA, 0=Port RB, 0=Port RC, etc.
volatile uint16_t * ptrDProvControlError
Pointer to external data buffer of most recent control error.
volatile bool differential_input
input channel differential mode enable bit
#define BUCK_VIN_ADC_TRGDLY
Input voltage ADC trigger delay.
#define BUCK_VOUT_ADCBUF
ADC input buffer of this ADC channel.
volatile struct BUCK_ADC_INPUT_SCALING_s scaling
normalization scaling settings
volatile bool upper_saturation_event
Bit 1: control loop is clamped at maximum output level.
volatile uint16_t duty_ratio_max
Absolute duty cycle maximum during normal operation.
volatile uint16_t usrParam7
generic 16-bit wide, user-defined parameter #8 for advanced control options
enum BUCK_CONTROL_MODE_e control_mode
Fundamental control mode.
#define BUCK_PWM_PHASE_SHIFT
This sets the phase shift between phase #1 and #2.
volatile bool interrupt_enable
input channel interrupt enable bit
#define BUCK_PWM2_CHANNEL
PWM peripheral output pins, control signals and register assignments of converter phase #2.
volatile bool adc_active
Bit #1: indicating that ADC has been started and samples are taken.
volatile uint16_t * ptrControlReference
Pointer to global variable of input register holding the controller reference value (e....
volatile uint16_t i_out
BUCK common output current.
volatile uint16_t usrParam6
generic 16-bit wide, user-defined parameter #7 for advanced control options
#define BUCK_PWM1_GPIO_INSTANCE
Number indicating device port, where 0=Port RA, 0=Port RB, 0=Port RC, etc.
#define BUCK_VIN_OFFSET
Input voltage feedback offset.
volatile struct NPNZ_GAIN_CONTROL_s GainControl
Parameter section for advanced control options.
volatile bool lower_saturation_event
Bit 0: control loop is clamped at minimum output level.
volatile struct BUCK_GPIO_SETTINGS_s gpio
BUCK converter additional GPIO specification.
volatile uint16_t no_of_phases
number of converter phases
#define BUCK_AGC_NOM_FACTOR
Fractional of the floating point number of the maimum limit of the adaptive gain modulation factor.
#define BUCK_VOUT_NORM_SCALER
VOUT normalization
#define BUCK_VOUT_TRIG_ADC
Buck VOUT control loop is called in ADC interrupt.
volatile uint16_t trigger_scaler
PWM triggers for ADC will be generated every n-th cycle.
volatile int16_t AltMaxOutput
Alternate maximum output value used for clamping (R/W)
volatile bool enabled
input channel enable bit
volatile uint16_t i_sns[BUCK_MPHASE_COUNT]
BUCK output current.
#define BUCK_VOUT_ADCCORE
0=Dedicated Core #0, 1=Dedicated Core #1, 8=Shared ADC Core
volatile uint16_t v_loop_Initialize(volatile struct NPNZ16b_s *controller)
Initializes controller coefficient arrays and normalization factors.
volatile uint16_t ExtHookEndFunctionParam
Parameter of function called (can be a variable or a pointer to a data structure)
volatile uint16_t appPowerSupply_PeripheralsInitialize(void)
This function is used to load peripheral configuration templates from the power controller device dri...
#define BUCK_VIN_ANSEL
GPIO analog function mode enable bit.
volatile uint16_t(* ctrl_Initialize)(volatile struct NPNZ16b_s *)
Function pointer to INIT routine.
#define BUCK_VIN_TRGSRC
PWM2 (=PG4) Trigger 1 via PGxTRIGA.
volatile uint16_t usrParam1
generic 16-bit wide, user-defined parameter #2 for advanced control options
#define BUCK_VIN_NORM_SCALER
VIN normalization
volatile bool suspend
Bit #6: Control bit to put the converter in suspend mode (turned off while ENABLE bit is still on)
#define BUCK_VOUT_ADC_TRGDLY
Macro calculating the integer number equivalent of the signal chain time delay between internal PWM t...
volatile bool enabled
Bit 15: enables/disables control loop execution.
#define BUCK_ISNS2_TRGSRC
PWM2 (=PG4) Trigger 2 via PGxTRIGB.
volatile int16_t minimum
output clamping value (minimum)
volatile bool swap_target
Bit 12: when set, AltTarget is used as data output of controller.
#define BUCK_PWM2_ADTR1OFS
ADC Trigger 1 Offset: 0...31.
volatile uint16_t duty_ratio_init
Initial duty cycle when the PWM module is being turned on.
volatile struct BUCK_FEEDBACK_SETTINGS_s feedback
BUCK converter feedback settings.
volatile uint16_t counter
Soft-Start Execution Counter (read only)
#define BUCK_PWM_DEAD_TIME_FE
Falling edge dead time [tick = 250ps].
#define BUCK_NO_OF_PHASES
User-declaration of global defines for PWM signal generator settings.
#define BUCK_VIN_ADCTRIG
Register used for trigger placement.
volatile int16_t offset
Signal offset as signed integer to be subtracted from ADC input.
volatile uint16_t duty_ratio_min
Absolute duty cycle minimum during normal operation.
#define BUCK_ISNS2_ADCCORE
0=Dedicated Core #0, 1=Dedicated Core #1, 2=Shared ADC Core
volatile struct NPNZ_PORTS_s Ports
Controller input and output ports.
volatile uint16_t ref_inc_step
Size/value of one reference increment/decrement or this period.
volatile fractional NormFactor
Q15 normalization factor.
volatile uint16_t port
GPIO port instance number (0=Port RA, 0=Port RB, 0=Port RC, etc.)
volatile struct NPNZ_STATUS_s status
Control Loop Status and Control flags.
volatile bool signed_result
input channel singed result mode enable bit
volatile uint16_t appPowerSupply_ConverterObjectInitialize(void)
This function initializes the buck converter device driver instance.
#define BUCK_PWM2_GPIO_PORT_PINH
Port Pin Number.
#define BUCK_ISNS2_OFFFSET
#define BUCK_ISNS1_ANSEL
GPIO analog function mode enable bit.
volatile bool async_mode
Bit #9: Control bit suspending the synchronous rectifier switch PWM channel.
volatile struct NPNZ_PORT_s AltTarget
Secondary data output port declaration.
volatile uint16_t ADCTriggerBOffset
ADC trigger #2 offset to compensate propagation delays.
void(* ctrl_Reset)(volatile struct NPNZ16b_s *)
Function pointer to RESET routine.
volatile uint16_t reference
Internal dummy reference used to increment/decrement controller reference.
volatile uint16_t pin
GPIO port pin number.
#define BUCK_AGC_IO_NORM_SCALER
Nominal VL Q15 scaler
#define BUCK_VOUT_OFFSET
Macro calculating the integer number equivalent of the physical, static signal offset of this feedbac...
#define BUCK_VIN_ADCBUF
ADC input buffer of this ADC channel.
volatile uint16_t v_in
BUCK input voltage.
#define BUCK_PWM2L_RPx
Device Pin output remappable pin number (RPx)
volatile uint16_t dead_time_rising
Dead time setting at rising edge of a half-bridge drive.
volatile uint16_t PPS_UnlockIO(void)
Unlocks the Peripheral Pin Select Configuration registers to enable changes.
volatile struct BUCK_CONVERTER_s buck
Global data object for a BUCK CONVERTER.
volatile uint16_t pwm_instance
number of the PWM channel used
#define BUCK_VOUT_ADCIN
Analog input number (e.g. '5' for 'AN5')
volatile uint16_t maximum
output clamping value (maximum)
volatile uint16_t ptrAgcObserverFunction
Function Pointer to Observer function updating the AGC modulation factor.
#define BUCK_PWM2_PDC
PWM Instance Duty Cycle Register.
volatile struct BUCK_CONVERTER_STARTUP_s startup
BUCK startup timing settings.
volatile uint16_t usrParam2
generic 16-bit wide, user-defined parameter #3 for advanced control options
volatile uint16_t ADCTriggerAOffset
ADC trigger #1 offset to compensate propagation delays.
volatile int16_t scaler
Feedback bit-shift scaler used for number normalization.
volatile fractional AgcFactor
Q15 value of Adaptive Gain Modulation factor.
volatile int16_t AltMinOutput
Alternate minimum output value used for clamping (R/W)
volatile struct BUCK_STARTUP_PERIOD_HANDLER_s i_ramp
#define BUCK_ISNS1_OFFFSET
volatile uint16_t * ptrDProvControlOutput
Pointer to external data buffer of most recent control output.
volatile uint16_t v_ref
User reference setting used to control the power converter controller.
#define BUCK_ISNS1_TRGSRC
PWM1 (=PG2) Trigger 2 via PGxTRIGB.
volatile struct BUCK_ADC_INPUT_SETTINGS_s ad_vout
ADC input sampling output voltage.
volatile bool ready
Bit #0: status bit, indicating buck converter is initialized and ready to run.
#define BUCK_ISNS1_ADCIN
Analog input number (e.g. '5' for 'AN5')
volatile bool cs_calib_complete
Bit #4: indicating that current sensor calibration has completed.
volatile uint16_t feedback_offset
Feedback offset value for calibration or bi-direction feedback signals.
#define BUCK_LEB_PERIOD
Leading Edge Blanking = n x PWM resolution (here: 50 x 2ns = 100ns)
volatile bool swap_outputs
Selecting if PWMxH (default) or PWMxL should be the leading PWM output.
#define BUCK_PWM1_PDC
PWM Instance Duty Cycle Register.
void v_loop_Precharge(volatile struct NPNZ16b_s *controller, volatile fractional ctrl_input, volatile fractional ctrl_output)
Prototype of the Assembly routine '_v_loop_Precharge' loading user-defined values into the NPNZ16b co...
#define BUCK_VOUT_ANSEL
ADC input assignments of output voltage feedback signals.
#define PWRGOOD_PORT
GPIO port declaration where 0=Port RA, 0=Port RB, 0=Port RC, etc.
volatile uint16_t PPS_RemapOutput(volatile uint8_t pinno, volatile uint8_t peripheral)
Assigns a digital function output to a pin.
volatile uint16_t usrParam0
generic 16-bit wide, user-defined parameter #1 for advanced control options
volatile struct BUCK_CONVERTER_STATUS_s status
BUCK operation status bits.
#define BUCK_PWM_DC_MIN
This sets the minimum duty cycle.
volatile struct NPNZ_PORT_s Target
Primary data output port declaration.
#define BUCK_PWM_PERIOD
This sets the switching period of the converter.
volatile struct BUCK_STARTUP_PERIOD_HANDLER_s power_on_delay
volatile bool invert_input
Bit 14: when set, most recent error input value to controller is inverted.
#define BUCK_ISNS1_ADCCORE
0=Dedicated Core #0, 1=Dedicated Core #1, 2=Shared ADC Core
#define BUCK_POD
Conversion Macros of Startup Timing Settings.
volatile struct BUCK_STARTUP_PERIOD_HANDLER_s power_good_delay
volatile uint16_t period
Switching period.
volatile uint16_t * ptrDProvControlInput
Pointer to external data buffer of most recent, raw control input.
volatile uint16_t leb_period
Leading-Edge Blanking period.
volatile bool autorun
Bit #14: Control bit determining if charger is starting automatically or on command (using the GO bit...
#define BUCK_VIN_NORM_FACTOR
VIN normalization factor scaled in Q15.
#define PWRGOOD_PIN
GPIO port pin declaration where 0=Rx0, 1=Rx1, 2=Rx3, etc.
volatile uint16_t dead_time_falling
Dead time setting at falling edge of a half-bridge drive.
volatile bool master_period_enable
Selecting MASTER or Individual period register.
volatile struct BUCK_LOOP_SETTINGS_s v_loop
BUCK voltage control loop object.
volatile struct NPNZ_DATA_PROVIDERS_s DataProviders
Automated data sources pushing recent data points to user-defined variables.
volatile uint16_t * ptrAddress
Pointer to register or variable where the value is read from (e.g. ADCBUFx) or written to (e....
volatile uint16_t * ptrADCTriggerBRegister
Pointer to ADC trigger #2 register (e.g. TRIG2)
#define BUCK_PWM_DEAD_TIME_LE
Rising edge dead time [tick = 250ps].
volatile uint16_t usrParam5
generic 16-bit wide, user-defined parameter #6 for advanced control options
#define BUCK_ISNS_REF
Conversion macros of phase current feedback parameters.
#define BUCK_PWM1_GPIO_PORT_PINL
Port Pin Number.
volatile uint16_t reference
Control loop reference variable.
volatile struct NPNZ_EXTENSION_HOOKS_s ExtensionHooks
User extension function triggers using function pointers with parameters.
volatile uint16_t gpio_low
GPIO port pin-number of PWMxL of the selected PWM generator.
volatile struct NPNZ_PORT_s AltSource
Secondary data input port declaration.
volatile uint16_t gpio_instance
GPIO instance of the selected PWM generator.
volatile uint16_t period
Soft-Start Period (POD, RAMP PERIOD, PGD, etc.)
volatile uint8_t adc_core
number of the ADC core connected to the selected channel
#define BUCK_AGC_IO_NORM_FACTOR
Nominal VL Q15 factor.
volatile uint16_t phase
Switching signal phase-shift.
void(* ctrl_Update)(volatile struct NPNZ16b_s *)
Function pointer to UPDATE routine.
volatile bool agc_enabled
Bit 11: when set, Adaptive Gain Control Modulation is enabled.
volatile bool enabled
Bit #15: Control bit enabling/disabling the charger port.
volatile bool cs_calib_enable
Bit #8: Flag bit indicating that current sensors need to calibrated.
volatile uint16_t trigger_offset
PWM triggers for ADC will be offset by n cycles.
#define BUCK_PWM_DC_MAX
This sets the maximum duty cycle.
volatile struct NPNZ_ADC_TRGCTRL_s ADCTriggerControl
Automatic ADC trigger placement options for ADC Trigger A and B.
volatile uint8_t trigger_source
input channel trigger source
volatile uint16_t v_out
BUCK output voltage.
volatile uint16_t * adc_buffer
pointer to ADC result buffer
volatile uint16_t AgcScaler
Bit-shift scaler of Adaptive Gain Modulation factor.
volatile uint16_t drv_BuckConverter_Initialize(volatile struct BUCK_CONVERTER_s *buckInstance)
This function initializes all peripheral modules and their instances used by the power controller.
volatile struct BUCK_ADC_INPUT_SETTINGS_s ad_vin
ADC input sampling input voltage.
volatile struct BUCK_CONVERTER_SETTINGS_s set_values
Control field for global access to references.
#define BUCK_ISNS_OFFSET_CALIBRATION_ENABLE
Enables/Disables Current Sense Offset Calibration.
volatile struct NPNZ_LIMITS_s Limits
Input and output clamping values.
volatile struct NPNZ_PORT_s Source
Primary data input port declaration.
#define BUCK_PWM2_GPIO_PORT_PINL
Port Pin Number.
volatile uint16_t appPowerSupply_ControllerInitialize(void)
This function initializes the control system feedback loop objects.
#define BUCK_VOUT_REF
Macro calculating the integer number equivalent of the output voltage reference given above in [V].
volatile struct NPNZ_USER_DATA_BUFFER_s Advanced
Parameter section for advanced user control options.
volatile uint16_t io_type
Input/Output definition (0=push-pull output, 1=input, 2=open-drain output)
#define BUCK_ISNS_NORM_SCALER
ISNS normalization
volatile struct BUCK_CONVERTER_DATA_s data
BUCK runtime data.
volatile uint16_t trigger_offset
ADC trigger offset value for trigger fine-tuning.
volatile int16_t MinOutput
Minimum output value used for clamping (R/W)
volatile bool enabled
Specifies, if this IO is used or not.
volatile uint16_t * ptrADCTriggerARegister
Pointer to ADC trigger #1 register (e.g. TRIG1)
#define BUCK_ISNS_NORM_FACTOR
ISNS normalization factor scaled in Q15.
volatile uint16_t i_ref
User reference setting used to control the power converter controller.
volatile struct BUCK_GPIO_INSTANCE_s PowerGood
Power Good Output.
#define BUCK_PWM1_ADTR1PS
ADC Trigger 1 Postscaler: 0...31.
void v_loop_Update(volatile struct NPNZ16b_s *controller)
Prototype of the Assembly feedback control loop routine helping to call the v_loop controller from C-...
#define BUCK_VOUT_TRGSRC
PWM1 (=PG2) Trigger 1 via PGxTRIGA.
#define BUCK_AGC_MEDIAN
Adaptive gain modulation factor at nominal operating point.
#define BUCK_VOUT_ADCTRIG
Register used for trigger placement.
#define BUCK_AGC_NOM_SCALER
Bit-shift scaler of the floating point number of the maimum limit of the adaptive gain modulation fac...
void(* ctrl_Precharge)(volatile struct NPNZ16b_s *, volatile fractional, volatile fractional)
Function pointer to PRECHARGE routine.
#define BUCK_ISNS1_ADCBUF
ADC input buffer of this ADC channel.
#define BUCK_ISNS2_ANSEL
GPIO analog function mode enable bit.
volatile struct NPNZ16b_s * controller
pointer to control loop object data structure
volatile fractional AgcMedian
Q15 value of Adaptive Gain Modulation nominal operating point.
volatile struct BUCK_GPIO_INSTANCE_s EnableInput
External ENABLE input.
volatile uint16_t temp
BUCK board temperature.
#define BUCK_PWM2_ADTR1PS
ADC Trigger 1 Postscaler: 0...31.
volatile uint16_t PPS_LockIO(void)
Locks the Peripheral Pin Select Configuration registers against accidental changes.
volatile int16_t Offset
Value/signal offset of this port.
volatile uint16_t ptrExtHookEndFunction
Pointer to Function which is called at the end of the control loop and will also be called when the c...
volatile struct BUCK_ADC_INPUT_SETTINGS_s ad_isns[BUCK_MPHASE_COUNT]
ADC input sampling phase current.
void v_loop_Reset(volatile struct NPNZ16b_s *controller)
Prototype of the Assembly routine '_v_loop_Reset' clearing the NPNZ16b controller output and error hi...
#define BUCK_VOUT_TRIGGER_MODE
Currently selected voltage loop interrupt vector.
volatile struct NPNZ16b_s v_loop
External reference to user-defined NPNZ16b controller data object 'v_loop'.
#define BUCK_ISNS2_ADCIN
Analog input number (e.g. '5' for 'AN5')
#define BUCK_VIN_ADCIN
Analog input number (e.g. '5' for 'AN5')
volatile int16_t factor
Fractional scaling factor (range -1 ... 0.99969)
#define BUCK_VIN_ADCCORE
0=Dedicated Core #0, 1=Dedicated Core #1, 8=Shared ADC Core
volatile struct BUCK_STARTUP_PERIOD_HANDLER_s v_ramp
volatile int16_t NormScaler
Bit-shift scaler of the Q15 normalization factor.
#define BUCK_PWM1_ADTR1OFS
ADC Trigger 1 Offset: 0...31.
volatile bool pwm_active
Bit #2: indicating that PWM has been started and ADC triggers are generated.
volatile bool early_interrupt_enable
input channel early interrupt enable bit
volatile bool level_trigger
input channel level trigger mode enable bit
volatile uint16_t usrParam3
generic 16-bit wide, user-defined parameter #4 for advanced control options
volatile int16_t MaxOutput
Maximum output value used for clamping (R/W)
#define BUCK_PWM2H_RPx
Device Pin output remappable pin number (RPx)
volatile bool high_resolution_enable
Selecting if PWM module should use high-resolution mode.
volatile bool fault_active
Bit #5: Flag bit indicating system is in enforced shut down mode (usually due to a fault condition)
volatile uint8_t adc_input
number of the ADC input channel used
volatile uint16_t usrParam4
generic 16-bit wide, user-defined parameter #5 for advanced control options
volatile struct BUCK_STATE_ID_s state_id
BUCK state machine operating state ID.
#define BUCK_PWM1_CHANNEL
PWM peripheral output pins, control signals and register assignments of converter phase #1.
volatile uint16_t polarity
Output polarity, where 0=ACTIVE HIGH, 1=ACTIVE_LOW.
volatile struct BUCK_SWITCH_NODE_SETTINGS_s sw_node[BUCK_MPHASE_COUNT]
BUCK converter switch node settings.
volatile uint16_t * ptrDProvControlInputCompensated
Pointer to external data buffer of most recent, compensated control input.
volatile bool sync_drive
Selecting if switch node is driven in synchronous or asnchronous mode.
#define BUCK_PWM1_GPIO_PORT_PINH
Port Pin Number.