| Digital Power Starter Kit 3 Firmware dsPIC33C Boost 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 /*********************************************************************************
14 * @fn void _BOOST_VLOOP_Interrupt(void)
15 * @ingroup app-layer-power-control-events
16 * @brief Main Control Interrupt
17 * @param void
18 * @return void
19 *
20 * @details
21 * The control interrupt is calling the control loop. The point in time where
22 * this interrupt is thrown is determined by selecting the BOOST_VOUT_TRIGGER_MODE
23 * option.
24 *
25 *********************************************************************************/
26
27 void __attribute__((__interrupt__, auto_psv, context))_BOOST_VLOOP_Interrupt(void)
28 {
29 #if (DBGPIN2_ENABLE)
30 DBGPIN2_Set();
31 #endif
32
33 // Set flag bit indication ADC interrupt activity
34 boost.status.bits.adc_active = true;
35
36 // Call feedback loop
37 #if (PLANT_MEASUREMENT == false)
38 boost.v_loop.ctrl_Update(boost.v_loop.controller);
39 #else
40 v_loop_PTermUpdate(&v_loop);
41 #endif
42
43 // Copy most recent control output to DAC output for debugging
44 #if (DBGDAC_ENABLE)
45 DACOUT_Set(boost.data.control_output);
46 #endif
47
48 // Clear the interrupt flag bit allowing the next interrupt to trip
49 _BOOST_VLOOP_ISR_IF = 0;
50
51 #if (DBGPIN2_ENABLE)
52 DBGPIN2_Clear();
53 #endif
54
55 }
56
57 // end of file
BOOST_LOOP_SETTINGS_s::controller
volatile struct NPNZ16b_s * controller
pointer to control loop object data structure
Definition: dev_boost_typedef.h:380
BOOST_LOOP_SETTINGS_s::ctrl_Update
void(* ctrl_Update)(volatile struct NPNZ16b_s *)
Function pointer to UPDATE routine.
Definition: dev_boost_typedef.h:384
BOOST_CONVERTER_STATUS_s::adc_active
volatile bool adc_active
Bit #1: indicating that ADC has been started and samples are taken.
Definition: dev_boost_typedef.h:210
BOOST_CONVERTER_DATA_s::control_output
volatile uint16_t control_output
BOOST most recent control output value.
Definition: dev_boost_typedef.h:332
BOOST_CONVERTER_s::v_loop
volatile struct BOOST_LOOP_SETTINGS_s v_loop
BOOST voltage control loop object.
Definition: dev_boost_typedef.h:539
BOOST_CONVERTER_s::data
volatile struct BOOST_CONVERTER_DATA_s data
BOOST runtime data.
Definition: dev_boost_typedef.h:533
BOOST_CONVERTER_s::status
volatile struct BOOST_CONVERTER_STATUS_s status
BOOST operation status bits.
Definition: dev_boost_typedef.h:529