This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Something simple

I'm trying without much success to write something fairly simple. Basically connect a signal to a pin, and run a function whenever that pin changes state. What's confusing me is how do I tie everything up so that my function is triggered based on the state of the pin. Is there example code anywhere? App note maybe? (The GPIOTE example is meant for toggling I/Os and I cannot quite understand from it how to do what I want. I've looked through the PPI documentation, but I'm afraid it is not very instructional for actually getting something done. I understand the theory, but lack the practical bit of how EVERYTHING is connected together from signal entry to execution.) I'm using the nRF51822 Evaluation Kit, and the SoftDevice.

Parents
  • Hi,

    I think you are over-engineering your problem a bit. Its not possible to have the GPIOTE/PPI to start a function call in such a "direct way". From your question, it seems like you want to generate an interrupt based on pin-change, and then run a function in code. This can be done using the GPIOTE PORT event. I am attaching an example on how to do this.

    However, if you'd like to trigger a "chain reaction", for instance that pin change starts the ADC or similar, you can do this with PPI/GPIOTE. I am also attaching a example that triggers ADC each RTC TICK.

    BR Håkon

    rtc_trigger_adc.c

    GPIOTE_Port_event.zip

Reply
  • Hi,

    I think you are over-engineering your problem a bit. Its not possible to have the GPIOTE/PPI to start a function call in such a "direct way". From your question, it seems like you want to generate an interrupt based on pin-change, and then run a function in code. This can be done using the GPIOTE PORT event. I am attaching an example on how to do this.

    However, if you'd like to trigger a "chain reaction", for instance that pin change starts the ADC or similar, you can do this with PPI/GPIOTE. I am also attaching a example that triggers ADC each RTC TICK.

    BR Håkon

    rtc_trigger_adc.c

    GPIOTE_Port_event.zip

Children
Related