Adding timer interrupt (100us) to Matter Demo

Hi all,

I would like to measure time intervals between gpio edges along with Matter. 

I tried to use a 100us timer interrupt but seems it will crash the original matter demo (Say light switch).

Not sure if the matter stack support this kind of operation?

Regards,

Brian

Parents
  • Hi,

    Based on your description, you could have a look at PPI Trace and PPI Trace sample. You can read more about PPI and PPI drivers in the documentation.

    Best regards,
    Dejan

  • Hi Dejan,

    Thanks for your kind advice, I will look into ppi trace but wonder if it can support 100us as ppi trace sample is 50ms based instead. In the meantime, wonder if nrf52840 supports timer input capture mode with dma? my application is actually decoding IR data packets and I just wonder to grab intervals between data edges (min. around 500us) . 

    Regards,

    Brian

  • Hi Brian,

    Could you please provide more information on what you are trying to achieve? Do you want to capture PWM signal at the output?

    50 ms is given as an example in the application, and this can be changed. You should be able to use PPI with your desired timer value. You could consider using PPI for registering the edges in similar way as sample does that. It is using alarm to toggle GPIO pins. You could potentially read the output of PWM or use PPI to generate events for starting and stopping the counter.

    Best regards,
    Dejan

  • Hi Dejan,

    Actually, I am trying to read IR signals (NEC protocol, min. pulse gap is around 500us) from a GPIO pin. We did it using NCS and nRF5 SDK (using a 100us timer to sample incoming gpio signal) but once we try to do the same in the matter light switch demo, the whole thing crashed. 

    Regards,

    Brian

  • Hi Brian,

    Could you provide more information about the integration of matter light switch demo with reading IR signals from GPIO pins? What is your starting point? What is your desired result?

    Best regards,
    Dejan

  • Hi Dejan,

    I just want to read an IR code and then trigger some matter features like light switching. Is it feasible? 

    I am thinking of receiving IR signal from a common IR receiver module (38kHz demodulated) and then try to get the pulse intervals and then decode them into IR codes. I have done that using NCS and nRF SDK wihtout the matter stack. Just wonder if possible to integrate into the matter stack. Any good references on this?

    Regards,

    Brian

  • Hi Brian,

    You could initialize NEC protocol in app_task.cpp Init() method, add some callbacks to process the data of IR signal and then use Event handling to handle measurements in Matter Zephyr's thread.

    Button handling is a good example how this can be done. In the AppTask::Init() method, there is initialization dk_buttons_init(ButtonEventHandler), then AppTask::ButtonEventHandler is called on each button interrupt and it calls specific GetAppTask().PostEvent() event which is executed by the Matter thread. An AppTask event callback connected to the IR measurement should contain updating the onoff cluster update as in AppTask::UpdateClusterState() method or simply change the LED state on the DK.

    Best regards,
    Dejan

Reply
  • Hi Brian,

    You could initialize NEC protocol in app_task.cpp Init() method, add some callbacks to process the data of IR signal and then use Event handling to handle measurements in Matter Zephyr's thread.

    Button handling is a good example how this can be done. In the AppTask::Init() method, there is initialization dk_buttons_init(ButtonEventHandler), then AppTask::ButtonEventHandler is called on each button interrupt and it calls specific GetAppTask().PostEvent() event which is executed by the Matter thread. An AppTask event callback connected to the IR measurement should contain updating the onoff cluster update as in AppTask::UpdateClusterState() method or simply change the LED state on the DK.

    Best regards,
    Dejan

Children
Related