Pin Change Interrupt Mask

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to set up a pin change routine on my Tiny2313. I want to have a pin mask that I can use to determine which pin changed and proceed from there.

What I have is an external guider for my telescope. It determines when the scope has drifted and flips a pin to signal which way to correct.

The pin change pins on the 2313 are on PortB also the OC0A and OC1A pins that I am using for the pulse train to the motors.

My question is how does the pin mask deal with the two pins on PortB that are changing constantly? I know that I can set which pins the interrupt responds to but the pin mask has me a bit puzzled.

Bob Parry

Bob Parry

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have to keep the previous values of the pins to compare to. If both are set previous to the interrupt, and one is set and one is clear at the time of the interrupt, then the one that is clear must have caused the interrupt.

Keep in mind that if the changes on the pins can be very fast, by the time you read the pins in the interrupt, the pin that caused the change may have returned to the original state. If your changes are slow, however, you don't have to worry about this.

Regards,
Steve A.

The Board helps those that help themselves.