Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Small Bug in FreqMeasure_capture.h

  1. #1
    Junior Member
    Join Date
    Apr 2015
    Posts
    13

    Small Bug in FreqMeasure_capture.h

    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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,112
    Are you looking at the latest version of FreqMeasure?

    That sound like a bug that was fixed in November 2014.

  3. #3
    Junior Member
    Join Date
    Apr 2015
    Posts
    13
    It looks like I worked with different version (and presumably an old one) that I downloaded from your site https://www.pjrc.com/teensy/td_libs_FreqMeasure.html (Version 1.1)

    It would be helpful to have the Version numbers commented in the libraries.
    My mistake clearly was getting it directly from the site thinking that that is where the latest rev lived.
    I will play with the latest and report.
    Thank you.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,112
    Oh, yup, many copies on the website are old.

    Removing all of them and replacing with links to github is on my TO-DO list....

  5. #5
    Junior Member
    Join Date
    Apr 2015
    Posts
    13
    Actually it was a great learning experience for me ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •