InitAdc();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.ADCINT=&ad;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable INT14 which is connected to CPU-Timer 2:
PieCtrl.PIEIER1.bit.INTx6=1;
IER |= M_INT1;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM