This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR6047: measuring integrated flow

Part Number: MSP430FR6047

Hello!

I have a question of calculating integrated flow.

1. We can set parameter of UPS0 to UPS1 Gap, but after I generate headers, I cannot find it in code.

 So please let me know the parameter name in code.

2. After logging, I open the file and there is a time stamp.

If I set UPS0 to UPS1 Gap  as 200ms, but the time stamp between delta tof if not 200ms, some of 200ms, and some of 190ms.

So I wonder the gap of result value is 200ms or not.

3. Is there to get integrated flow?

Thanks.

  • Hi Nakyoung,

    I am working to find the appropriate expert to help you. This may take some time to reach the right person depending on availability. Please expect an update by Tuesday. I appreciate your patience.

    Best,

    -Chris

  • Hello Nakyoung,

    The UPS0 to UPS1 delay is not included in the headers generated from the GUI.  You can find this in USS_App_userConfig.h.

    /* Delay time between captures in ACLK (32768Hz) cycles */
    #define USS_APP_CAPTURE_DELAY_ACLK                  (32768)

       

  • Thanks for response!

    I set #define USS_APP_CAPTURE_DELAY_ACLK        (16343)

    And I open  logging CSV file.

    The logged delta tof period is not 500ms.

    The captured file is below.

    The period of data is not 500ms. 

    So I wonder the alg_results_float is saved per 500ms or not.

    Thank you.

    NK Yoo

  • Nakyoung,

    The delay function in the code today will not provide very high precision as it is executed from the start of each measurement and it is possible that the algorithm computation can take a longer or shorter period depending on the data captured.  Also, it looks like you are measuring the logged data from the GUI, which could also have some variation creating the time stamp with the I2C communication and GUI interface.  

    If you would like very precise timing, you could implement an interrupt timer based solution as shown below.  

    ----------------------------------------
    #pragma vector= USS_APP_PERIODIC_MEASUREMENT_TIMER_CCR0_VECTOR
    __interrupt void USS_APP_PERIODIC_MEASUREMENT_TIMER_INT(void)
    ----------------------------------------
    
    Files that need modification:
    1.	USS_App_userConfig.c:
    2.	USS_App_userConfig.h:
    3.	USSLibGUIApp.c
    
    ----------------------------------------------------------------------------
    USSLibGUIApp.c:
    ----------------------------------------------------------------------------
    /* Enables Timer Based capture frequency */
    #ifdef USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
    uint16_t captureCyclePeriod;
    #endif
    
    // For INITIALIZATION; NOT INSIDE THE WHILE LOOP ****
    #ifdef USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
        // Initialize the Measurement (Capture) Timer duration
        captureCyclePeriod = USS_APP_CAPTURE_FREQ_ACLK;
        USS_APP_initCaptureTimer(captureCyclePeriod);
        USS_APP_startCaptureTimer();
    #endif
    
    // INSIDE THE WHILE LOOP: (Instead of the DELAY)
    
    #ifndef USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
            if (gUssSWConfig.measurementConfig->pulseConfig->AFCisEnabled == false)
            {
                USSLibGUIApp_Delay();     /* Delay for proper time  */
            }
    #else
            if (gUssSWConfig.measurementConfig->pulseConfig->AFCisEnabled == false)
            {
                USS_APP_waitForTimerInt();
                USS_APP_restartCaptureTimer();
            }
    #endif
    ----------------------------------------------------------------------------
    USS_App_userConfig.h:
    ----------------------------------------------------------------------------
    /* Enables Timer Based capture frequency */
    #ifdef USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
    #define USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS (TIMER_A3_BASE)
    #if (USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS==TIMER_A3_BASE)
    #define USS_APP_PERIODIC_MEASUREMENT_TIMER_CCR0_VECTOR  (TIMER3_A0_VECTOR)
    #endif
    #endif
    /* Delay time between captures in ACLK (32768Hz) cycles */
    //Timer interrupt duration in ACLK cycles for capture frequency
    #define USS_APP_CAPTURE_FREQ_SECONDS              (1)
    #define USS_APP_CAPTURE_FREQ_ACLK                 ((32768-2)*USS_APP_CAPTURE_FREQ_SECONDS)
    
    #ifdef USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
    //! \brief function to initialize the Timer used to control the capture frequency
    //!
    extern void USS_APP_initCaptureTimer(uint16_t captureTimerCounts);
    
    //! \brief function to start the Timer used to control the capture frequency
    //!
    extern void USS_APP_startCaptureTimer(void);
    
    //! \brief function to restart the Timer used to control the capture frequency
    //!
    extern void USS_APP_restartCaptureTimer(void);
    
    //! \brief function to wait for the timer interrupt to fire
    //!
    extern void USS_APP_waitForTimerInt(void);
    #endif // end of USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
    ----------------------------------------------------------------------------
    USS_App_userConfig.c:
    ----------------------------------------------------------------------------
    
    #ifdef USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
    volatile uint16_t timerSWFlag, timerOverflow;
    
    void USS_APP_initCaptureTimer(uint16_t captureTimerCounts)
    {
        //Init flags
        timerSWFlag = false;
        timerOverflow = false;
        // Timer uses ACLK. CLK Div /1. Stop mode. Clear TAR
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCTL) = (TASSEL__ACLK | ID__1 | MC__STOP | TACLR);
        // Disable CCR0 interrupt by default. Compare mode
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCCTL0) = 0x00;
        // TAx.0 used to trigger the start of the next capture sequence
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCCR0) = captureTimerCounts;
    }
    
    void USS_APP_startCaptureTimer(void)
    {
        // Enable CCR0 interrupt
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCCTL0) = CCIE;
        // Start Timer in up mode
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCTL) = (TASSEL__ACLK | TACLR | MC__UP);
    }
    
    void USS_APP_restartCaptureTimer(void)
    {
        // Restart Timer in up mode
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCTL) = (TASSEL__ACLK | TACLR | MC__UP);
    }
    
    void USS_APP_waitForTimerInt(void)
    {
        __disable_interrupt();
        //If timerSWFlag is true at this point, then the interrupt has already fired and the timer has already stopped, thus signaling an overflow
        if( timerSWFlag == true )
        {
            timerOverflow = true;
        }
        //If there was no overflow, then wait in the while loop for the timer interrupt to fire
        else
        {
            while( timerSWFlag == false )
            {
                __bis_SR_register(LPM3_bits + GIE);
                __disable_interrupt();
            }
        }
    
        timerSWFlag = false; //Always clear the timerSWFlag when returning from the function to start a new capture sequence
    
        __bis_SR_register(GIE);
    
    }
    
    #pragma vector= USS_APP_PERIODIC_MEASUREMENT_TIMER_CCR0_VECTOR
    __interrupt void USS_APP_PERIODIC_MEASUREMENT_TIMER_INT(void)
    {
        //Stop the timer
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCTL) = (TASSEL__ACLK | ID__1 | MC__STOP | TACLR);
    
        //Set the Timer flag
        timerSWFlag = true;
    
        //Clear the interrupt flag and wake up from LPM3 on return
        HARDWAREWREG16(USS_APP_PERIODIC_MEASUREMENT_TIMER_BASE_ADDRESS + OFS_TAxCCTL0) &= ~(CCIFG);
        LPM3_EXIT;
    }
    #endif // end of USS_APP_PERIODIC_MEASUREMENT_TIMER_ENABLE
    

**Attention** This is a public forum