Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example
app_power_control_isr.c
1 /*
2  * File: app_power_control_isr.c
3  * Author: M91406
4  *
5  * Created on May 26, 2020, 7:32 PM
6  */
7 
8 
9 #include "config/hal.h"
10 #include "app_power_control.h"
11 #include "drivers/v_loop.h"
12 
13 
27 void __attribute__((__interrupt__, auto_psv, context))_BUCK_VLOOP_Interrupt(void)
28 {
29  #if (DBGPIN2_ENABLE)
30  DBGPIN2_Set();
31  #endif
32 
33  // Set flag bit indication ADC interrupt activity
34  buck.status.bits.adc_active = true;
35 
36  // Call feedback loop
37  #if (PLANT_MEASUREMENT == false)
39  #else
41  #endif
42 
43  // Copy most recent control output to DAC output for debugging
44  #if (DBGDAC_ENABLE)
46  #endif
47 
48  // Clear the interrupt flag bit allowing the next interrupt to trip
50 
51  #if (DBGPIN2_ENABLE)
52  DBGPIN2_Clear();
53  #endif
54 
55 }
56 
57 // end of file
v_loop
volatile struct NPNZ16b_s v_loop
External reference to user-defined NPNZ16b controller data object 'v_loop'.
Definition: v_loop.c:94
BUCK_LOOP_SETTINGS_s::ctrl_Update
void(* ctrl_Update)(volatile struct NPNZ16b_s *)
Function pointer to UPDATE routine.
Definition: dev_buck_typedef.h:357
BUCK_CONVERTER_s::status
volatile struct BUCK_CONVERTER_STATUS_s status
BUCK operation status bits.
Definition: dev_buck_typedef.h:502
DBGPIN2_Set
#define DBGPIN2_Set()
Macro instruction to set a pin state to logic HIGH.
Definition: dpsk3_hwdescr.h:210
v_loop_PTermUpdate
void v_loop_PTermUpdate(volatile struct NPNZ16b_s *controller)
Prototype of the alternate Assembly P-Term control loop helping to call the v_loop P-Term controller ...
DACOUT_Set
#define DACOUT_Set(x)
Direct SFR Write Access Macro for Digital-To-Analog Converter instance #1.
Definition: dpsk3_hwdescr.h:270
_BUCK_VLOOP_ISR_IF
#define _BUCK_VLOOP_ISR_IF
Interupt vector flag bit register bit.
Definition: dpsk3_hwdescr.h:755
BUCK_CONVERTER_DATA_s::control_output
volatile uint16_t control_output
BUCK most recent control output value.
Definition: dev_buck_typedef.h:306
BUCK_CONVERTER_s::data
volatile struct BUCK_CONVERTER_DATA_s data
BUCK runtime data.
Definition: dev_buck_typedef.h:506
_BUCK_VLOOP_Interrupt
#define _BUCK_VLOOP_Interrupt
Interrupt vector function call label.
Definition: dpsk3_hwdescr.h:753
BUCK_LOOP_SETTINGS_s::controller
volatile struct NPNZ16b_s * controller
pointer to control loop object data structure
Definition: dev_buck_typedef.h:353
BUCK_CONVERTER_STATUS_s::adc_active
volatile bool adc_active
Bit #1: indicating that ADC has been started and samples are taken.
Definition: dev_buck_typedef.h:209
DBGPIN2_Clear
#define DBGPIN2_Clear()
Macro instruction to set a pin state to logic LOW.
Definition: dpsk3_hwdescr.h:211
BUCK_CONVERTER_s::v_loop
volatile struct BUCK_LOOP_SETTINGS_s v_loop
BUCK voltage control loop object.
Definition: dev_buck_typedef.h:512
buck
volatile struct BUCK_CONVERTER_s buck
Global data object for a BUCK CONVERTER.
Definition: app_power_control.c:28