12-14-2021 08:31 AM
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.
Solved! Go to Solution.
12-14-2021 08:50 AM
Hello pallyapd,
What is BSEC version you would like to use?
12-14-2021 09:48 AM
I used bsec_1-4-8-0_generic_release
12-14-2021 10:07 AM
12-16-2021 06:46 AM
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 .