AnsweredAssumed Answered

Capture rising edge

Question asked by Futte on Mar 6, 2013
Latest reply on Sep 10, 2013 by Filippo Visocchi

unsigned int irPort;

  //Port initialisering

  definePort();

  fnDebugMsg("IR\n");

  irPort = _READ_PORT_MASK(C, PORTC_BIT6);

  fnDebugDec(irPort, 0);

 

  //Enable the Clock to the FTM0 Module

  SIM_SCGC6 |= SIM_SCGC6_FTM0;

  FTM0_SC |= FTM_SC_PS_1; // clock prescaler / 1

 

  //turn off FTM write protection;

  FTM0_MODE |= FTM_MODE_WPDIS;

  FTM0_MODE |= FTM_MODE_FTMEN;

 

  FTM0_SC = 0x0;

  FTM0_SC = 0; //Make sure its Off!

 

  FTM0_CNT = 0; //Reset counter, make sure we are starting at 0

  FTM0_MOD = (FTM_CSC_ELSA | FTM_CSC_ELSB);  //Set the overflow rate

  //FTM0_MOD = IRQ_RISING_EDGE;

 

  FTM0_SC |= FTM_SC_TOIE; //Enable the interrupt mask.

  FTM0_SC |= FTM_SC_CLKS_SYS; //Select the System Clock

 

  fnDebugMsg("Timer is running, with value: ");

  //fnDebugDec(FTM0_CNT, 0);

  fnDebugDec(FTM0_MOD, 0);

 

Outcomes