Calling k_event_post from Interrupt context in zephyr RTOS

Hello All, 

I am using RTC interrupt handle on the NRF5340 kit to set the event using k_event_post API from the interrupt context and when I try to wait on this event in the main function using k_event_wait it is never set the event and when I tried to debug using the NRF5340 kit debugger it works using the debugger but when the NRF controller run in freerun mode it didn't work.

and here is the example I am using to test this scenario. 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <zephyr.h>
#include <sys/util.h>
#include <sys/printk.h>
#include <string.h>
#include <stdlib.h>
#include <nrfx_rtc.h>
#include <nrfx_timer.h>
#include <nrfx_dppi.h>
#include <nrfx_gpiote.h>
#include <hal/nrf_gpiote.h>
#include <hal/nrf_timer.h>
#include <hal/nrf_gpio.h>
#define LED_0 28
#define LED_1 29
#define LED_2 30
#define COMPARE_COUNTERTIME 3
#define RTC_EVENT_PENDING (1 << 2)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks, 

Parents
  • I have tried to use your code and I see the same. Not sure why the waiting thread does not stop waiting even though clearly the rtc interrupt handler posts the event. Seems simple to use but does not work. Anyone else in this forum use this successfully? Can't see any modules using this in the application in our sdk.

  • Hi Susheel, 

    when I was testing didn't work even after 1 minute the issue when I called the k_event_post from interrupt didn't work so is there an issue in Zephyr or do we need to make a special configuration for this?

    Thanks, 

Reply
  • Hi Susheel, 

    when I was testing didn't work even after 1 minute the issue when I called the k_event_post from interrupt didn't work so is there an issue in Zephyr or do we need to make a special configuration for this?

    Thanks, 

Children