        volatile    uint16_t    Voltage_meas;
        volatile    uint16_t    Current_meas;
#define MAX_POWER_LOSS          100000

extern  void    PrerOutpTask ( void ) {
    uint32_t    pwmvalue;
    uint16_t    portvalue;

    // See if the maximum power loss is exceeded
     if  ( (uint32_t)MAX_POWER_LOSS < (uint32_t)Current_meas * (uint32_t)(Prereg_meas - Voltage_meas) ) {
        // The max power was exceeded.
        // We need to calculate value that does not exceed it
        // U = P / I
        pwmvalue = (uint32_t)MAX_POWER_LOSS / (uint32_t)Current_meas;
        pwmvalue += (uint16_t)(Voltage_set + Voltage_off);
    }

    // Since it was not exceeded we set prereg = 20 Volts + Voltage_set
    else {
        pwmvalue = (uint16_t)200 + Voltage_set + Voltage_off;
    }

    // Convert into 8 bit PWM control byte
    pwmvalue *= (uint16_t)255;
    portvalue = pwmvalue / (uint16_t)OUT_MAX_PRER;
    if  ( portvalue > 255 ) {
        portvalue = 255;
    }

    // Set the PWM
    OCR2 = (uint8_t)(portvalue & 0xFF);
}