How to get GPIO register state in GPIOTE handler

Hello Nordic! My question probably a simple one but I'm a novice so there's it. I'm looking for a way to get a GPIO port state that was at the moment of GPIOTE event triggering, inside the event handler. Is there any register I can read to get that?

The context: I'm trying to read a two line serial bus of TitanMicro TM1640. The start of transmission is designated by falling DIN line while SCLK line is still high. The time between falling DIN and falling SCLK is about 10 us, so when I'm reading the GPIO from the handler the SCLK is already low.

Parents Reply
  • Hi,

    Unfortunately, it is not possible to capture digital levels on GPIOs using PPI.

    Some potential workarounds:

    1) You can configure the GPIOTE to generate an event on GPIO rising edge, falling edge or any change for the SCLK input.
    You can then configure a TIMER instance in counter mode, and use it to keep track of how many times the GPIOTE event has been generated.
    If you know the initial gpio state(high/low), then you also know the current GPIO state simply by looking at the counter value.
    Trigger the TIMER CC capture task using PPI with the GPIOTE event for the DIN. Then in the GPIO handler, you can read TIMER CC register, and based on that value you can know if the SCLK was high or low.

    2) Use SAADC, see this post:  RE: Is it possible to read a data pin with PPI? (PS/2 bit banging using PPI) 

Children
Related