Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Adaptive Gain 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
#define _BUCK_VLOOP_Interrupt
Interrupt vector function call label.
#define _BUCK_VLOOP_ISR_IF
Interupt vector flag bit register bit.
#define DBGPIN2_Set()
Macro instruction to set a pin state to logic HIGH.
#define DBGPIN2_Clear()
Macro instruction to set a pin state to logic LOW.
#define DACOUT_Set(x)
Direct SFR Write Access Macro for Digital-To-Analog Converter instance #1.
volatile struct BUCK_CONVERTER_s buck
Global data object for a BUCK CONVERTER.
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 ...
volatile struct NPNZ16b_s v_loop
External reference to user-defined NPNZ16b controller data object 'v_loop'.
Definition: v_loop.c:98
volatile bool adc_active
Bit #1: indicating that ADC has been started and samples are taken.
volatile uint16_t control_output
BUCK most recent control output value.
volatile struct NPNZ16b_s * controller
pointer to control loop object data structure
void(* ctrl_Update)(volatile struct NPNZ16b_s *)
Function pointer to UPDATE routine.
volatile struct BUCK_CONVERTER_STATUS_s status
BUCK operation status bits.
volatile struct BUCK_LOOP_SETTINGS_s v_loop
BUCK voltage control loop object.
volatile struct BUCK_CONVERTER_DATA_s data
BUCK runtime data.