Need help with IO Pin used as interrupt

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaHu_285096
Level 5
Level 5
10 likes received 250 replies posted 100 replies posted

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.

0 Likes
1 Solution
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

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

View solution in original post

0 Likes
2 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

user_343349849,

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.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

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

0 Likes