Description of example project
==============================
This example implements a Buck Converter in Voltage Control mode
for being used together with the XMC Digital Power Explorer kit.
The project is implemented using XMC4200, a 32-bit ARM Cortex M4
based microcontroller with FloatingPoint Unit. In addition, it also has dedicated control peripherals
such as the HRPWM module for high resolution PWM generation and a Versatile Analog-to-Digital
(VADC) module for analog signal measurement, making it suitable for applications that require fast
calculation such as the Voltage Control mode.

The voltage Control loop is implemented by a classic 3 poles 3 zeros filter using floating points values.
The provided filter coefficients has been selected to have the following controller characteristics:
 + Switching freq = 200kHz
 + Crossover freq = 10kHz
 + Phase margin   = 50 degrees
 + PWM master clock = 20,480GHz = 80MHz *256 (8 bits for HRPWM)
 + PWM resolution = 150 ps
 + ADC resolution = 12 bits 
 
VADC conversion is being continuously triggered by the Compare Match 2 of  CCU8 (set by default to the maximum = period value).
Once the output voltage has being measured by the VADC, an interrupt is generated. 
Inside the ISR, the 3 poles 3 zeros controller is applied and new value for the duty cycle is updated.

 ADC Trigger                        ADC Trigger
    ;                                   :
    ;_______                            :________
PWM |    <--|-->                        |     <--|-->
____|  20%  |___________________________|  20%   |_______
    ;                                   :
    ;                                   :
    ;   ADC                             :   ADC
    ;<--------> __________              :<--------> __________
ISR ;          | Filter + |             :          | Filter + |
    ;          |  HRPWM   |             :          |  HRPWM   |
____;__________|  update  |_____________:__________|  update  |_______

One instance of each of those DAVE 4 APPs have been used to easy the peripherals configuration:

HRPWM (High resolution PWM, generates the ADC trigger through the CCU8 peripheral and the HRPWM)
ADC_MEASUREMENT_ADV(Output Voltage measurement)
INTERRUPT (NVIC configuration)

Filter related APIs are implemented in the xmc_3p3z_filter_float.h file
while the PWM initialization and control ISR are implemented in the main.c.
   
Hardware Setup
===============
XMC4200 Digital Power Control Card + XMC Digital Power Explorer Kit
Vout P14.6
CCU8 direct output P0.4
CCU8 inverted output P2.15
HRPWM out0 P0.5
HRPWM out1 P0.2
Vin  P14.3 (not measured in project)

How to test the application
============================
a. Import the project
b. Prepare board set up: connect XMC4200 Digital Power Control Card into 
    XMC Digital Power Explorer and supply power with included power adapter to it. 
    Make sure power on switch is in the "on" position and that the jumper in power board
	is in the XMC4000 position	
c. Compile and flash the application onto the device 
d. Run the application.
e  Check via oscilloscope the different test points available
   in XMC Digital Power Explorer.
   Vout is now controlled to be stable at 3,3 V independent of load switching
   LEDs next to load switches must turn on when that particular load is activated
f. If changes are needed in APPs configuration, make sure code is generated again before compiling
