DAC MCP4922

Merci Artouste, tu pourrai me donner ( si possible ) un exemple en l'appliquant a mon code pour la convertion de "val_Num"?

void setup()
{
 
  
  Serial.begin (115200);
  noInterrupts();           // disable all interrupts

  /* initialisation timer3 mode CaptureToCompare*/

  TCCR3A = 0;
  TCCR3B = 0;
  TCNT3  = 0;

  OCR3A = 125; // compare match register 16MHz/256/2Hz // interrupt every 1 ms
  TCCR3B |= (1 << WGM32);   // CTC mode
  TCCR3B |= (1 << CS32);    // 256 prescaler
  TIMSK3 |= (1 << OCIE3A);  // enable timer compare interrupt

  /*Initialisation timer5 mode InputCompare*/

  TCCR5A = 0;
  TCCR5B = 0;
  TCNT5  = 0;
  TCCR5B |= (1 << CS50);// 8 prescaler
  TCCR5B |= (1 << ICES5);// Rising


  interrupts();             // enable all interrupts
}

/*Trigger*/

ISR(TIMER3_COMPA_vect)          // interrupt fonction
{
  TIMSK5 |= (0 << ICIE5);
  DDRB = (1 << DDB4); //Pin 10 en mode OUTPUT
  PORTB = (0 << PORTB4); // Pin 10 à 0
  delayMicroseconds(9); // temps a l'état bas du trigger
  PORTB = (1 << PORTB4); // Pin 10 à 1

  // PASSEAGE EN INPUT POUR LIRE LA REPONSE DU CAPTEUR
  DDRB = ( 0 << DDB4); // Pin 10 en entrée et attente de la réponse capteur
  TIMSK5 |= (1 << ICIE5);//enable Input Capture interrupt
}


ISR(TIMER5_CAPT_vect)
{
  TCNT5 = 0;
  Buffer[ buff_index ] = (ICR5); //(48 = 3*16) 3 = prédiv capteur, et 16 clock/µs
  Buffer[ buff_index ] = ((ICR5 / 43) - 11); //(48 = 3*16) 3 = prédiv capteur, et 16 clock/µs
  buff_index ++;
  if (buff_index == size_buff)
  {
    buff_index = 0;
  }
}

void loop()
{
  Serial.println("New trame");
  for ( i = 4, j = 0; i < 8, j < 4; i++, j++)
  {
    Nibble [j] = Buffer [i];
    val_Num_16 = (Nibble[3] + (Nibble[2] << 4) + (Nibble[1] << 8) + (Nibble[0] << 12));
  }
  //Serial.println (val_Num_16); // buffer reader
  val_Num_12 = map(val_Num_16, 0, 65535, 0, 4095);
  Serial.println (val_Num_12); // buffer reader
}

cordialement.