Description of example project
==============================
This example implements a Buck Converter in Peak Current Control mode
for being used together with the 600W buck solar optimizer. 
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 = 200kHz
 + current loop control freq = 50kHz
 + voltage loop control freq = 25kHz
 + ADC sampling time for 3 signals (Vin, IL, Iin) in sequence is almost 3us for one time
 + 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.
   
How to test the application
============================
a. Import the project and adjust the starting MPPT voltage target close to the actual maximum power point  of your 
    setup to speed up tracking; Line 295 mppt_pno1.VmppOut whereas 315=10V
b. Prepare board set up: connect the solar optimizer board to a PV emulator or panel and connect a sufficient large load to it
    so that the maximum power point can be reached
c. Compile and flash the application onto the device 
d. Run the application.
e  Check via oscilloscope different points on the boards
   Vin is now controlled and changed slightly each 2s indicated by the blue LED
f. If changes are needed in APPs configuration, make sure code is generated again before compiling
