You should use buck converter with adjustable backfeed as loop, controlled by MCU. PWM can be used as a DAC.
Or you can use PWM to drive mosfet directly and calculate PWM duty based on current and voltage feedback, converted by ADC.
The first one methode is more difficult, but gives you h/w independed circuit with protection from mcu stuck.
Second one requers very high speed PWM, so the MCU's frequency should be very high to realise necessary PWM accuracy.
For 6 bit PWM working on 300kHz your MCU frequency should be about 40Mhz.