2 Replies Latest reply on Feb 1, 2019 9:21 PM by GeonaP_26

    Need help with IO Pin used as interrupt


      I have a pin that is used for dual function.

      At startup the pin is used to calibrate a clock (so I have set the pin up as digital input with interrupt that increments a count. I measure frequency by number of count in sample window) - this works fine.


      After setup, the pin is used to read synchronous data (This is the data pin and another pin is the clock). However, I cannot figure out how to read the pin when it is set up as interrupt? What is the syntax to read the value of this pin, is it accessed by name of the component (in this case "INT_WAKE", which has several other interrupt pins assigned also in this port 2).


      I did consider changing pin and using a counter to measure frequency and then use as normal input later but could not figure out how to set up the counter.


      If using port as interrupt and digital input is tricky, is there a simply example of using the counter? In this case I would hope to simply start timer in code, wait a sample time and then read a value of how many pulses counted.


      Thanks in advance.

        • 1. Re: Need help with IO Pin used as interrupt


          You should be to achieve what you want.


          First off, once you're done with the pin as an interrupt in the first task, you should disable the interrupt.  This prevents useless (and possibly erroneous) CPU processing.  There are multiple ways of disabling the interrupt.  It is usually best to disable it from an API call from the component that originally enabled it.  If you share your project, I believe I can help here.


          For the second task, ALL port pins are accessible as direct reads.  The best way is to use the name you assigned to the pin  with the following command.  I believe you called it INT_WAKE.  Therefore in this case use:  INT_WAKE_Read().


          There is a generic way to read the pin digital value by accessing it by the port number.   However then you need to parse the specific bit you're using.


          I hope this helps.



          • 2. Re: Need help with IO Pin used as interrupt

            Please refer Digital Pins code example available in PSoC Creator. It demonstrates using interrupt and <Pin_name>_Read() together.