  | 
  
    Digital Power Starter Kit 3 Firmware
    
   dsPIC33C Buck Converter Voltage Mode Control Example 
   | 
           
 | 
 
 
 
 
   12 #include "dev_buck_pconfig.h"  
   13 #include "dev_buck_typedef.h"  
   14 #include "dev_buck_substates.h"  
   15 #include "dev_buck_special_functions.h"  
   56     volatile uint16_t _i=0;
 
   87     return(BUCK_OPSRET_COMPLETE); 
 
  106     volatile uint16_t retval=1;
 
  107     volatile uint16_t _i=0;
 
  141         return(BUCK_OPSRET_COMPLETE);
 
  143         return(BUCK_OPSRET_ERROR);
 
  161     volatile uint16_t retval=0;
 
  166     { buckInstance->
status.bits.
GO = 
true; }
 
  174         case BUCK_OPSRET_COMPLETE:
 
  178         case BUCK_OPSRET_REPEAT:
 
  181             return(BUCK_OPSRET_REPEAT);
 
  186             return(BUCK_OPSRET_ERROR);
 
  200         buckInstance->
status.bits.
GO = 
false;
 
  201         return(BUCK_OPSRET_COMPLETE);
 
  206         return(BUCK_OPSRET_REPEAT);
 
  227     volatile uint16_t retval=0;
 
  235         return(BUCK_OPSRET_ERROR);
 
  245         case BUCK_OPSRET_REPEAT:
 
  247             retval = BUCK_OPSRET_REPEAT;
 
  254         case BUCK_OPSRET_COMPLETE:
 
  262                 retval = BUCK_OPSRET_REPEAT;
 
  264                 if (buckInstance->
state_id.
bits.substate_id == BUCK_OPSTATE_I_RAMP_UP)
 
  277                 retval = BUCK_OPSRET_COMPLETE;
 
  286             retval = BUCK_OPSRET_ERROR;        
 
  348     return(BUCK_OPSRET_REPEAT);
 
  365     volatile uint16_t retval=0;
 
  374         retval = BUCK_OPSRET_COMPLETE;
 
  376         retval = BUCK_OPSRET_ERROR;
 
  
 
volatile uint16_t BuckStateList_size
Buck converter state machine function pointer array size
 
volatile uint16_t(* BuckConverterStateMachine[])(volatile struct BUCK_CONVERTER_s *buckInstance)
Buck converter state machine function pointer array.
 
volatile uint16_t reference
Control loop reference variable.
 
volatile struct BUCK_CONVERTER_STARTUP_s startup
BUCK startup timing settings.
 
volatile uint16_t counter
Soft-Start Execution Counter (read only)
 
volatile uint16_t State_Error(volatile struct BUCK_CONVERTER_s *buckInstance)
If this function is called, the state machine is reset to INITIALIZE (URL=State_Initialize).
 
volatile struct BUCK_STARTUP_PERIOD_HANDLER_s v_ramp
 
volatile uint16_t drv_BuckConverter_SpecialFunctionExecute(volatile struct BUCK_CONVERTER_s *buckInstance, volatile enum BUCK_SPECIAL_FUNCTIONS_e specialFunction)
This is the public function call access point to call dedicated special sub-functions.
 
enum BUCK_CONTROL_MODE_e control_mode
Fundamental control mode.
 
volatile uint16_t buckPWM_Suspend(volatile struct BUCK_CONVERTER_s *buckInstance)
This function disables the PWM generator IOs.
 
volatile struct BUCK_LOOP_SETTINGS_s i_loop[BUCK_MPHASE_COUNT]
BUCK Current control loop objects.
 
volatile struct BUCK_CONVERTER_STATUS_s status
BUCK operation status bits.
 
volatile uint16_t State_Reset(volatile struct BUCK_CONVERTER_s *buckInstance)
This function resets the buck control operation by re-initiating the control mode,...
 
volatile bool busy
Bit #7: Flag bit indicating that the state machine is executing a process (e.g. startup-ramp)
 
volatile struct NPNZ_PORT_s Target
Primary data output port declaration.
 
volatile bool fault_active
Bit #5: Flag bit indicating system is in enforced shut down mode (usually due to a fault condition)
 
volatile uint16_t State_Standby(volatile struct BUCK_CONVERTER_s *buckInstance)
This function waits until all start-up conditions are met.
 
volatile bool suspend
Bit #6: Control bit to put the converter in suspend mode (turned off while ENABLE bit is still on)
 
volatile struct NPNZ_STATUS_s status
Control Loop Status and Control flags.
 
volatile struct BUCK_STARTUP_PERIOD_HANDLER_s power_on_delay
 
volatile int16_t MinOutput
Minimum output value used for clamping (R/W)
 
volatile bool enabled
Bit 15: enables/disables control loop execution.
 
volatile bool ready
Bit #0: status bit, indicating buck converter is initialized and ready to run.
 
volatile uint16_t(* BuckConverterRampUpSubStateMachine[])(volatile struct BUCK_CONVERTER_s *buckInstance)
Buck converter state machine function pointer array.
 
void(* ctrl_Reset)(volatile struct NPNZ16b_s *)
Function pointer to RESET routine.
 
volatile uint16_t v_ref
User reference setting used to control the power converter controller.
 
volatile bool cs_calib_enable
Bit #8: Flag bit indicating that current sensors need to calibrated.
 
volatile uint16_t ref_inc_step
Size/value of one reference increment/decrement or this period.
 
volatile struct BUCK_CONVERTER_SETTINGS_s set_values
Control field for global access to references.
 
volatile bool cs_calib_complete
Bit #4: indicating that current sensor calibration has completed.
 
volatile uint16_t State_RampUp(volatile struct BUCK_CONVERTER_s *buckInstance)
This function ramps up the voltage/input to its nominal value.
 
volatile bool pwm_active
Bit #2: indicating that PWM has been started and ADC triggers are generated.
 
volatile uint16_t BuckRampUpSubStateList_size
Buck converter sub-state machine function pointer array size.
 
volatile struct NPNZ16b_s * controller
pointer to control loop object data structure
 
volatile struct NPNZ_LIMITS_s Limits
Input and output clamping values.
 
volatile bool adc_active
Bit #1: indicating that ADC has been started and samples are taken.
 
BUCK control & monitoring data structure.
 
struct BUCK_STATE_ID_s::@3::@4 bits
 
volatile struct BUCK_STATE_ID_s state_id
BUCK state machine operating state ID.
 
volatile struct BUCK_STARTUP_PERIOD_HANDLER_s power_good_delay
 
volatile uint16_t State_Initialize(volatile struct BUCK_CONVERTER_s *buckInstance)
This function resets the counters and conditional flag bits.
 
volatile struct BUCK_LOOP_SETTINGS_s v_loop
BUCK voltage control loop object.
 
volatile bool GO
Bit #13: When set, the GO-bit fires up the power supply.
 
volatile struct NPNZ_PORTS_s Ports
Controller input and output ports.
 
volatile uint16_t no_of_phases
number of converter phases
 
volatile uint16_t State_Online(volatile struct BUCK_CONVERTER_s *buckInstance)
This function tunes the controller reference to the new user control reference level.
 
volatile uint16_t * ptrAddress
Pointer to register or variable where the value is read from (e.g. ADCBUFx) or written to (e....
 
volatile bool enabled
Bit #15: Control bit enabling/disabling the charger port.
 
volatile bool autorun
Bit #14: Control bit determining if charger is starting automatically or on command (using the GO bit...