Hi,
I'm trying to synchronize a process using an nRF52833 dev kit using a Zephyr event.
The code looks like this:
void collect_power_sample(int timer) { tat_config_params_t *c = (tat_config_params_t *)reach_timer_user_data_get(sampling_timer); // LOG_INF("Collecting sample %d", power_readings.num_samples); nrf_gpio_pin_set(SET_TIMER_PIN); get_power_sample(); if (--(c->num_samples) == 0) { reach_put_timer(sampling_timer); k_event_set(&sample_ready_evt, REACH_SAMPLE_READY_EVT); nrf_gpio_pin_set(DONE_PIN); LOG_INF("Samples ready"); } else { nrf_gpio_pin_set(SAMPLE_PIN); reach_timer_set( sampling_timer, (uint32_t)reach_get_timestamp() + c->delta_between_samples, collect_power_sample ); } nrf_gpio_pin_clear(SAMPLE_PIN); nrf_gpio_pin_clear(SET_TIMER_PIN); } void process_power_reading_cmd(void) { nrf_gpio_pin_set(SET_TAT_PIN); if (k_event_wait(&sample_ready_evt, REACH_SAMPLE_READY_EVT, true, K_SECONDS(1))) { nrf_gpio_pin_clear(SET_TAT_PIN); nrf_gpio_pin_clear(DONE_PIN); send_power_samples(); } else { LOG_ERR("%s timeout waiting for power sampling", __func__); } }
The first routine sends an event and the second captures it. I hooked up an analyzer to SET_TAT_PIN and DONE PIN and I'm observing this behavior:
The top and bottom pins are hooked to the GPIOs I mentioned. It looks like the event behaves as a k_sleep rather than an event!
If I change the timeout on the event to 10 seconds the high period changes to 10 seconds. This event should return immediately!
Further, I don't see the line "timeout waiting for power sampling" which should show up in case of event timing out.
Have you seen this type of behavior?
I'm using timer 4 for accurate time measurement, would that be affecting this behavior?
Thanks,
Guy.