cancel
Showing results for 
Search instead for 
Did you mean: 

Best setting for free-running timer BlueNRG-1

Diltech
Associate II

How is the best configuration for setting MTF as free-running timer ?

void MFT_Configuration()
{
  MFT_InitType timer_init;
  NVIC_InitType NVIC_InitStructure;
  
  SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_MTFX1, ENABLE);
  
  /* Init MFT1 in mode 2 */
  timer_init.MFT_Clock1 = MFT_PRESCALED_CLK;
  timer_init.MFT_Clock2 = MFT_NO_CLK;
  timer_init.MFT_Mode = MFT_MODE_2;
  timer_init.MFT_CRA = 0xFFFF;
  timer_init.MFT_CRB = 0xFFFF;
  
 /* If a square waveform is @ input with a frequency of 10kHz => T = 100 us
  *
  * with Prescaler = 16 - 1; => 1us sampling period
  * the counter number within a period is 100.
  * 
  * with Prescaler = 1 - 1; => 62.5ns sampling period
  * the counter number within a period is 16000. More resolution.
  */
  timer_init.MFT_Prescaler = 1-1;
  
  MFT_Init(MFT1, &timer_init);
  
  /* Set the TnCNT1 at the max value. No matter about the TnCNT2 since it is not used. */
  MFT_SetCounter(MFT1, 0xFFFF, 0xFFFF);
  
  /* Enable MFT irq */
  NVIC_InitStructure.NVIC_IRQChannel = MFT1A_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}

 

Thank

0 REPLIES 0