AnsweredAssumed Answered

FTM Mode "Enable DMA" K60

Question asked by Jensen Kenneth on Oct 10, 2013
Latest reply on Oct 23, 2013 by Jensen Kenneth

Hi

 

I'm working on a K60 MCU and I have tried to use DMA along with a flextimer.

 

I can see in the manual that the mode for the flextimer can be set to enable DMA. Nothing else is mentioned about this using flextimers.

I've tried several guides and examples, but they are hard to understand.

 

I have no clue how to implement DMA, but I understand the principles. Is there a very basic example out there, where for instance when an rising edge occur the value of the counter can be transferred by DMA? Or can anyone take me through step-by-step how to implement it.

In my head, when the K60 offers the opportunity to enable DMA for flextimer by a single bit, it shouldn't be so hard to setup as the DMA-ADC example.

I'm using uTasker and I posted my code beneath. I hope someone can help me out, I've been stuck to this for weeks now.

 

Thanks in advance.

 

 


void ftm_init(void)
{
  POWER_UP(6, SIM_SCGC6_FTM0); // Enable clock 
  PORTC_PCR1 = PC_1_FTM0_CH0; // 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_COMBINE = ( FTM_COMBINE_COMBINE0 | FTM_COMBINE_DECAPEN0 | FTM_COMBINE_DECAP0 ); // Channels combined, Dual edge capture enabled and activated.

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

  // Capture set to rising edge (ELSB:ELSA = 0:1) and Mode set to continious (MSA:MSB = 1:0) on both channels
  FTM0_C0SC = (FTM_CSC_ELSA | FTM_CSC_MSA | FTM_CSC_DMA);
  FTM0_C1SC = (FTM_CSC_ELSA | FTM_CSC_MSA | FTM_CSC_DMA | FTM_CSC_CHIE);  


  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 
}







Outcomes