Hello,
I'm using MQX 4.0 with K60.
I would like to use input capture on Rising edge or falling edged.
I can't succeed to have counting.
Here is the code :
//Enable FlexTimer 3 Clock |
SIM_SCGC3 |= SIM_SCGC3_FTM3_MASK;; /* Enable clock for FTM3 */
PORTE_PCR10|= (0|PORT_PCR_ISF_MASK|PORT_PCR_MUX(6)); |
// FTM0_CH5 |
FTM3_MODE |= FTM_MODE_WPDIS_MASK; |
FTM3_CNT = 0; | //reset the counter to zero |
FTM3_MOD = 0xffff ; | //Set the overflow rate |
FTM3_CNTIN = 0; | //Set the Counter Initial Value to 0 |
FTM3_MODE |= FTM_MODE_FTMEN_MASK; |
// FLEX Timer0 configuration |
FTM3_SC |= (FTM_SC_PS(0)| FTM_SC_CLKS(1)); |
// TOF=0 TOIE=0 CPWMS=0 CLKS=01 (system clock) (divide by 1) |
FTM3_C1SC = 0; | /* Clear channel status and control register */ |
FTM3_C2SC = 0; | /* Clear channel status and control register */ |
FTM3_C3SC = 0; | /* Clear channel status and control register */ |
FTM3_C4SC = 0; | /* Clear channel status and control register */ |
FTM3_C5SC = 0; | /* Clear channel status and control register */ |
FTM3_C6SC = 0; | /* Clear channel status and control register */ |
FTM3_C7SC = 0; | /* Clear channel status and control register */ |
FTM3_C5SC |= (0|FTM_CnSC_ELSA_MASK | FTM_CnSC_CHIE_MASK); |
FTM3_MODE |= FTM_MODE_FTMEN_MASK; |
FTM3_COMBINE = 0; |
FTM3_QDCTRL = 0; |
//Enable the counter to run in the BDM mode |
FTM3_CONF |= FTM_CONF_BDMMODE(0); |
Can you help me please ?
Regards,
Guillaume
Hello, Mark and Soledad.
I will give you more details on waht I want to obtain.
I want to use the FTM 3 to count pulse on the channel 5.
I already have the FTM1 and FTM2 cofidured with quadrature mode.
When I configure the FTM3 in input capture mode, when I read the C5V register (for the channel 5), I always have 0.
I want to read the register periodically and reset it when I have read it.
I checked the signal which is on the GPIO and the signal is good.
The cofigured register seems to be correct. But the register still remain at 0.
I didn't found any documentation on it.
Is there something wrong in my code?
Regards,
Guillaume
Hi,
Please check the attached file, this may helps!!!
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Guillaume
There is another discussion at the moment about this: Callback Overhead in KL03 running at 48 Mhz
With code that you can copy.
Regards
Mark
Kinetis: µTasker Kinetis support
K60: µTasker Kinetis TWR-K60N512 support / µTasker Kinetis TWR-K60D100M support / µTasker Kinetis TWR-K60F120M support
For the complete "out-of-the-box" Kinetis experience and faster time to market