Hello,
While playing with the FreqMeasure Library I was hoping to get two independent channels to measure frequency.
This brought me to looking at the FreqMeasure_capture.h and realizing that the #if defined(CAPTURE_USE_FTM1_CH0) was the same for the CH1 as well as the FTM2 CH0 and CH1.
The issue as far as I can tell is that the CORE_PINX needs to reflect the proper pin assigned to each FMT channel.
static inline void capture_start(void)
{
FTM1_C0SC = 0b01000100;
CORE_PIN3_CONFIG = PORT_PCR_MUX(3);
NVIC_ENABLE_IRQ(IRQ_FTM1);
static inline void capture_shutdown(void)
{
FTM1_C0SC = 0;
CORE_PIN3_CONFIG = 0;
NVIC_DISABLE_IRQ(IRQ_FTM1);
}
So... I am pretty sure that the flowing solution that worked for me can be far more elegant, but the only way I was able to make two independently measuring channels was to have two separate sets of library's each with separate definition for the FMT1 and FMT2 with separate init to each and FreqMeasure and FreqMeasure1 functions.
What is not clear to me is how can I obtain the results from the FTM1 and FTM2 channels using a single library.
Also after reading the MK20DX256 reference manual I have some idea how to manipulate the FTM's to be able to do different timing measurement but for the life of me I am not able to figure out how to change the registers.
For example how to set the Dual Edge Capture mode.
Any hints or examples on manipulating the FTMs will be greatly appreciated.
Fyi Tennsy 3.1 @ 96 MHz measures both channels independently in excess of 600 KHz. Pretty impressive!
Best regards
While playing with the FreqMeasure Library I was hoping to get two independent channels to measure frequency.
This brought me to looking at the FreqMeasure_capture.h and realizing that the #if defined(CAPTURE_USE_FTM1_CH0) was the same for the CH1 as well as the FTM2 CH0 and CH1.
The issue as far as I can tell is that the CORE_PINX needs to reflect the proper pin assigned to each FMT channel.
static inline void capture_start(void)
{
FTM1_C0SC = 0b01000100;
CORE_PIN3_CONFIG = PORT_PCR_MUX(3);
NVIC_ENABLE_IRQ(IRQ_FTM1);
static inline void capture_shutdown(void)
{
FTM1_C0SC = 0;
CORE_PIN3_CONFIG = 0;
NVIC_DISABLE_IRQ(IRQ_FTM1);
}
So... I am pretty sure that the flowing solution that worked for me can be far more elegant, but the only way I was able to make two independently measuring channels was to have two separate sets of library's each with separate definition for the FMT1 and FMT2 with separate init to each and FreqMeasure and FreqMeasure1 functions.
What is not clear to me is how can I obtain the results from the FTM1 and FTM2 channels using a single library.
Also after reading the MK20DX256 reference manual I have some idea how to manipulate the FTM's to be able to do different timing measurement but for the life of me I am not able to figure out how to change the registers.
For example how to set the Dual Edge Capture mode.
Any hints or examples on manipulating the FTMs will be greatly appreciated.
Fyi Tennsy 3.1 @ 96 MHz measures both channels independently in excess of 600 KHz. Pretty impressive!
Best regards