3.3kW Totem-pole PFC with SiC and XMC1404
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Background

Files

file  init_bckgnd_funct.c
 Functions for SW initialization and running in the background during operation.
 
file  init_bckgnd_funct.h
 Header of the functions for SW initialization and running in the background during operation.
 

Macros

#define FLASH_CLK_DIV   (10)
 
#define FLASH_SLEEP_DLY   (3000000 >> 10)
 

Functions

void MATH_DIV_config ()
 DIV kernel of the MATH co-processor initialization.
Used in the input RMS feedforward. More...
 
void control_loop_init ()
 Assign value to the coefficients of voltage and current loops.
Reset the state and output of both controllers.
Reset current offset calculation variables.
Set initial power for inverter operation. More...
 
void IIR_param_init (void)
 IIR coefficients initialization.
IIR cascaded low-pass filter of the AC voltage to obtain the RMS value.
IIR notch filter of the DC voltage to remove 100/120Hz ripple.
Sampling frequency of both filters is 2500Hz, every 2 cycles of CCU40.CC41 @ 5kHz. More...
 
void time_counter ()
 Time counter is a background process to count "real-time" in the application. More...
 
void delay_100us (uint32_t time)
 Delay function. More...
 
void PFC_INV_mode ()
 Operation mode (PFC - AC/DC or inverter - DC/AC) selection function.
Decision taken only once when starting the application. More...
 
void input_voltage_observer ()
 BOP protection, checking AVG input voltage.
The function modifies the control status register. More...
 
void flash_sleep_ctr ()
 Flash memory sleep state control. More...
 

Variables

static uint16_t flash_sleep_cnt = FLASH_SLEEP_DLY
 

AC voltage filter variables

volatile IIR_lowpass_int_t ACfilter
 
volatile int32_t auxAC = 0
 

DC-bus voltage filter variables

volatile IIR_lowpass_int_t DCfilter
 
volatile int32_t auxDC = 0
 

Controller structures

volatile controller_int_t voltage_int_ctr
 
volatile controller_PI_t current_PI_ctr
 
volatile bool power_stage_ON = false
 
volatile bool current_loop_ON = false
 

Time counters

uint8_t _1ms_count = 0
 
uint8_t _100ms_count = 0
 
uint8_t time_BOP = 0
 
uint8_t time_ACOK = 0
 
uint8_t time_PLD_130V = 0
 
uint8_t time_PLD_150V = 0
 
uint8_t time_V_step = 0
 
uint16_t time_INIT = 200
 
uint8_t time_extra_bulk = 0
 

Input voltage monitoring flags

static bool BOP_flag_150V = false
 
static bool BOP_flag_130V = false
 

Detailed Description

Macro Definition Documentation

#define FLASH_CLK_DIV   (10)

Flash memory control clock divider. [control_cyc/2^FLASH_CLK_DIV]

#define FLASH_SLEEP_DLY   (3000000 >> 10)

Flash sleep delay. 30 seconds.

Function Documentation

void control_loop_init ( void  )

Assign value to the coefficients of voltage and current loops.
Reset the state and output of both controllers.
Reset current offset calculation variables.
Set initial power for inverter operation.

Returns
None
void delay_100us ( uint32_t  time)

Delay function.

Parameters
timeWait time in multiples of 100us
Returns
None
void flash_sleep_ctr ( )
inline

Flash memory sleep state control.

Returns
None
void IIR_param_init ( void  )

IIR coefficients initialization.
IIR cascaded low-pass filter of the AC voltage to obtain the RMS value.
IIR notch filter of the DC voltage to remove 100/120Hz ripple.
Sampling frequency of both filters is 2500Hz, every 2 cycles of CCU40.CC41 @ 5kHz.

Returns
None
void input_voltage_observer ( void  )

BOP protection, checking AVG input voltage.
The function modifies the control status register.

Returns
None
void MATH_DIV_config ( void  )

DIV kernel of the MATH co-processor initialization.
Used in the input RMS feedforward.

Returns
None
void PFC_INV_mode ( void  )

Operation mode (PFC - AC/DC or inverter - DC/AC) selection function.
Decision taken only once when starting the application.

Parameters
None
Returns
None
void time_counter ( void  )

Time counter is a background process to count "real-time" in the application.

Returns
None

Variable Documentation

uint8_t _100ms_count = 0

100ms counter.

uint8_t _1ms_count = 0

1ms counter.

volatile IIR_lowpass_int_t ACfilter

AC-RMS Filter instance

volatile int32_t auxAC = 0

Scaled AC voltage for filter operation

volatile int32_t auxDC = 0

Scaled DC voltage for filter operation

bool BOP_flag_130V = false
static

PLD voltage flag.

bool BOP_flag_150V = false
static

PLD voltage flag.

volatile bool current_loop_ON = false

State Machine sets if the current control loop is evaluated

volatile controller_PI_t current_PI_ctr

Current controller.

volatile IIR_lowpass_int_t DCfilter

Bulk-Notch Filter instance

uint16_t flash_sleep_cnt = FLASH_SLEEP_DLY
static

30 seconds delay to set flash into sleep.

volatile bool power_stage_ON = false

State Machine sets if the Power Stage (PWM) can be turned on

uint8_t time_ACOK = 0

Not used, debugging of LCDO detection

uint8_t time_BOP = 0

Not used, debugging of start-up sequence

uint8_t time_extra_bulk = 0

Counter to increase bulk reference after AC lost (LCDO).

uint16_t time_INIT = 200

Counter to start/resume operation. [ms]

uint8_t time_PLD_130V = 0

Counter for PLD timing definition.

uint8_t time_PLD_150V = 0

Counter for PLD timing definition.

uint8_t time_V_step = 0

Counter to define time step during voltage ramp in PFC soft-start.

volatile controller_int_t voltage_int_ctr

Voltage controller.