enable DMA transfers in input capture mode FTM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

enable DMA transfers in input capture mode FTM

1,308 Views
kenrenjen
Contributor III

Hi

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

}

Labels (1)
Tags (3)
3 Replies

574 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Kenneth,

The attached file will be helpful for you. Good luck with you.

I'm look forward for your reply.

574 Views
kenrenjen
Contributor III

Thank you for your reply :smileyhappy: The document is very useful, but I am a little bit confused about how to initialize it properly.

I was wondering if I am able to only use one register to transfer (counting) the number of overflows, which my free running FTM counter has exceeded. Instead of manually counting it by overflow interrupt.

This is the only thing I want to use DMA for, but do it has to be that complicated to set up as it describes in the document you posted?

Thanks again. :smileyhappy:

0 Kudos

574 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Kenneth,

I‘m glad to hear that the AN4693 is helpful for you. Have you figured out how to use DMA transfer the capture value by FTM module?

If you still don't have any ideas about that, Maybe the samle code will give you a hint.

Regards,

Ping

0 Kudos