AnsweredAssumed Answered

enable DMA transfers in input capture mode FTM

Question asked by Jensen Kenneth on Sep 17, 2013
Latest reply on Sep 21, 2013 by jeremyzhou



I have enabled DMA transfer for flextimer. How does it exactly works? how do I read/write data from the registers.


I can't find any documents which describes this technology well and I need some examples.


I hope someone can help me out.


Thanks in advance.


//Initialisation of capture
void ftm_init(void)
  POWER_UP(6, SIM_SCGC6_FTM0); // Enable clock 
  PORTC_PCR1 = PORT_MUX_ALT4; // Multiplexer (MUX) for flextimer (FTM) initialized to port FTM0 and channel 0  (route the desired signal to the pin)
  FTM0_MODE = (FTM_MODE_WPDIS | FTM_MODE_FTMEN); // Disable write protection

  FTM0_CONF = FTM_CONF_BDMMODE_3; // FTM_DEBUG_BEHAVIOUR: Allow timer to continue operating when debugging  

  FTM0_CNTIN = 0x0000; // Counter initial value
  FTM0_MOD = 0xFFFF; // Modulo to max

  FTM0_C0SC = (FTM_CSC_ELSA | FTM_CSC_CHIE | FTM_CSC_DMA); // Capture set to rising edge (ELSB:ELSA = 0:1) and enable channel interrupt 

  FTM0_SC = (FTM_SC_CLKS_SYS | FTM_SC_PS_1 | FTM_SC_TOIE); // Sets the source to system clock and define the prescalar. Timer overflow interrupt enabled (1)

  fnEnterInterrupt(irq_FTM0_ID, PRIORITY_HW_TIMER, ftm0_isr); //Configure and enter the ftm0 handling interrupt routine in the vector table