Description of example project
==============================
This example implements a Buck Converter in Peak Current Control mode
for being used together with the XMC Digital Power Explorer kit. Visit www.infineon.com/xmc_dp_exp.
The project is implemented using XMC1300, a 32-bit ARM Cortex M0
based microcontroller. It has dedicated control peripherals
such as the CCU8 and CCU4 PWM modules for PWM generation, fast and precise Analog Comparators and a Versatile Analog-to-Digital
(VADC) module for analog signal measurement, making it suitable for applications that require fast
calculation such as the Peak Current Control mode.

The current Control loop is implemented by a classic 2 poles 2 zeros filter using floating points values.
The provided filter coefficients has been selected to have the following controller characteristics:
 + Switching freq = 100kHz
 + Crossover freq = 5kHz
 + Phase margin   = 50 degrees
 + PWM resoluiton = 15.625 ns
 + ADC resolution = 12 bits 

Test results may vary depending on board configuration, in particular RC filter value. Please check documentation for more details.
VADC conversion is being continuously triggered by the Compare Match 2 of the 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 2 poles 2 zeros controller is applied and new value of the DAC(CCU4 PWM + external filter) slope start is set.
ADC Trigger                        ADC Trigger
   ;                                   :
   ;_______                            :________
PWM|    <--|-->                        |     <--|-->
___|  20%  |___________________________|  20%   |_______
   ;                                   :
   ;                                   :
   ;   ADC                             :   ADC
   ;<--------> __________              :<--------> __________
ISR;          | Filter + |             :          | Filter + |
   ;          |  CCU4    |             :          |  CCU4    |
___;__________|  update  |_____________:__________|  update  |_______

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

PWM_CCU8 (PWM, generates the ADC trigger through the CCU8 peripheral(Compare Match 2) and the PWM(Compare Match 1))
ADC_MEASUREMENT_ADV(Output Voltage measurement)
INTERRUPT (NVIC configuration)
COMP_REF(Configuration of the Analog Comparator and CCU4 for the reference)

Filter related APIs are implemented in the xmc_2p2z_filter_fixed.h file
while the PWM initialization and control ISR are implemented in the main.c.
   
Hardware Setup
===============
XMC1300 Digital Power Control Card + XMC Digital Power Explorer Kit
Vout P2.3
CCU8 direct output P0.0
CCU8 inverted output P0.5
CCU4 output 0.9
Comparator INN pin 2.8
Comparator INP pin 2.9
Vin  P2.10 (not measured in project)

How to test the application
============================
a. Import the project
b. Prepare board set up: connect XMC1300 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 XMC1000 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
