Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    NRF52840 with BME680

    NRF52840 with BME680

    pallyapd
    Established Member

    hello
    I am using nrf52840 with a segger embedded system I want to calculate IAQ using app timer which is generated interrupt every 3-second(LP mode) to call bsec_ iot_loop(), that's working for me .but when I call this loop every 5 minutes (300-sec ULP mode ) not able to get calculate IAQ .i develop get_timerstamp_us as below .please help me 

    static void my_timer_start(void) {
    // Reset the second variable
    my_timer_seconds = 0;

    // Ensure the timer uses 24-bit bitmode or higher
    MY_TIMER->BITMODE = TIMER_BITMODE_BITMODE_24Bit << TIMER_BITMODE_BITMODE_Pos;

    // Set the prescaler to 4, for a timer interval of 1 us (16M / 2^4)
    MY_TIMER->PRESCALER = 4;

    // Set the CC[0] register to hit after 1 second
    MY_TIMER->CC[0] = 1000000;

    // Make sure the timer clears after reaching CC[0]
    MY_TIMER->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk;

    // Trigger the interrupt when reaching CC[0]
    MY_TIMER->INTENSET = TIMER_INTENSET_COMPARE0_Msk;

    // Set a low IRQ priority and enable interrupts for the timer module
    NVIC_SetPriority(MY_TIMER_IRQn, 7);
    NVIC_EnableIRQ(MY_TIMER_IRQn);

    // Clear and start the timer
    MY_TIMER->TASKS_CLEAR = 1;
    MY_TIMER->TASKS_START = 1;
    }

    static uint32_t my_timer_get_ms(void) {
    // Store the current value of the timer in the CC[1] register, by triggering the capture task
    MY_TIMER->TASKS_CAPTURE[1] = 1;

    // Combine the state of the second variable with the current timer state, and return the result
    return (my_timer_seconds * 1000) + (MY_TIMER->CC[1] / 1000);
    }

    /*!
    * @brief Capture the system time in microseconds
    *
    * @return system_current_time current system timestamp in microseconds
    */

    static int64_t get_timestamp_us() {
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "in get us loop timestamp : %d\n\n",((int64_t)my_timer_get_ms() * 1000));

    return ((int64_t)my_timer_get_ms() * 1000);
    }


    // Timer interrupt handler
    void MY_TIMER_IRQHandler(void) {
    if (MY_TIMER->EVENTS_COMPARE[0]) {
    MY_TIMER->EVENTS_COMPARE[0] = 0;

    // Increment the second variable
    my_timer_seconds++;
    }
    }

    1)is it compulsory to use sample rate  LP or ULP mode for calculating IAQ.
    2)my system is battery-operated so want to increase this sample rate for example every 15 minutes how to achieve this.


    7 REPLIES 7

    BSTRobin
    Community Moderator
    Community Moderator

    Hello pallyapd,

    What is BSEC version you would like to use?

    pallyapd
    Established Member

    I used bsec_1-4-8-0_generic_release

    BSTRobin
    Community Moderator
    Community Moderator

    Hello pallyapd,

    You could refer attachment code used the same BSEC version with you.

    pallyapd
    Established Member

    thanks for responding to me. in the attached file they create a separate task for BME680 .is any other way to calculate IAQ.? what about the sampling rate ...?is it must use LP or ULP my system is battery-operated so want to custom sample rate how to overcome this problem. In my  setup, IAQ works only LP or ULP .

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist