bonjour,
je travaille sur un microcontroleur ATxmega128A1 sous avr studio4. pour la simulation j'utilise le kit stk600. donc je veux mesurer la fréquence émise par le GBF et je veux une précision de 40ppm, mon probléme c'est que j'arrive pas a atteindre cette précision (6100ppm O_o) voici ma fonction :
Code:
 
#include "usart_driver.h"
#include "avr_compiler.h"
#include "adc_driver.h"
#include "clksys_driver.h"
#define F_CPU           31803465UL
#define CPU_PRESCALER   1
#include "TC_driver.h"
#define USART USARTE0
volatile int8_t offset;
envoi_frequence()
{
  static uint32_t frequency=0;
  static uint32_t totalPeriod;
  uint32_t thisCapture;
uint8_t c=100;
uint32_t r=0;
/* Configure PC0 for input, triggered on both edges. */
	PORTC.PIN0CTRL = PORT_ISC_RISING_gc;
	PORTC.DIRCLR = 0x01;

	/* Select PC0 as input to event channel 0. */
	EVSYS.CH2MUX = EVSYS_CHMUX_PORTC_PIN0_gc;

	/* Configure TCC0 for Input Capture using event channel 2. */
	TC0_ConfigInputCapture( &TCC0, TC_EVSEL_CH2_gc );

	/* Enable Input "Capture or Compare" channel A. */
	TC0_EnableCCChannels( &TCC0, TC0_CCAEN_bm );
	
	/* Clear MSB of PER[H:L] to allow for propagation of edge polarity. */
	TC_SetPeriod( &TCC0, 0x7FFF );

	
	/* Start timer by selecting a clock source. */
	TC0_ConfigClockSource( &TCC0, TC_CLKSEL_DIV1_gc );

	 
TC_ClearCCAFlag( &TCC0 ) ;
	while(c!=0)
   {	 
      do {
			/* Wait for Input Capture. */
		} while ( TC_GetCCAFlag( &TCC0 ) == 0 );
		TC_ClearCCAFlag( &TCC0 ) ;
		TC_Restart( &TCC0 );
    do {
			/* Wait for Input Capture. */
		} while ( TC_GetCCAFlag( &TCC0 ) == 0 );
	 if(TC_GetOverflowFlag( &TCC0)==1)
	 {
	   thisCapture = TC_GetCaptureA( &TCC0 );
	   totalPeriod = (thisCapture & 0x7FFF)+32767;

	 }
	 else
		{thisCapture = TC_GetCaptureA( &TCC0 );
		totalPeriod = (thisCapture & 0x7FFF);
       }
		TC_ClearCCAFlag( &TCC0 ) ;
		TC_ClearOverflowFlag( &TCC0);
		TC_Restart( &TCC0 );
		
		c--;
    }
   TC0_Reset(&TCC0);
   frequency =  ( ( F_CPU / (CPU_PRESCALER) ) / totalPeriod )/2;
merci de m'aider