interrupt example needed

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

I have been working at least 9 hours trying to get a tiny26 to respond to a pin change interrupt on PA6...does anyone have a simple example, gauranteed to work?
I have tried setting GIMSK, DDRA & portA every which way, to no avail. My interrupt routine runs just fine--it is just never being called. This is an actual board, not a simulator. I am using the correct interrupt vector (third one on the list).

I am assuming what occurs on the other pins does not matter (I can't get ANY pin change interrupts & would be happy if any occurred at all).

Should I be doing something with GIFR? It is unclear if this needs to be touched--though I've tried a few things.
Ithionnk I need a small known working sample to see just what the H*** is going wrong. I even checked my signal going into the pin!

What does the interrupt consider to be a "change" & at what point is it considered a change? I am tapping wires low & high, so there should be plenty of interrupting going on.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Hi,

I did a quick check of your recent posts regarding this matter and did not see any code examples of what you have tried. My apologies if I missed some. Can you post your code (or point to the thread where you did)?

Maybe it is something as simple as forgeting to do a "SEI"...just a thought.

Regards,
Steve

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

ity would be tough to po0st all of the 30-100 ways I've tried to get this working...that;'s why I need a 10 line example that is known to work.

I've set ddra to $20 & $60. Port a to both $20 & $F0. I'm assuming the port pin just needs to be set as an input.

Ive tried setting ACSR to 00

I generally set GIMSK to $20, though Ive tried $30 as well (in case PEIC0 & PIEC1 were swapped in the manual).

I set SEI & have tried doing it multiple places.

I've mess with GIFR too.

I checked out the ISR routine & it works fine when you call it.---It is just never called as an interrupt. I save the sreg and restore it (though it would not matter since I never even get it to run once--let alone worry about returng!).

I checked that the coreect vector is being used (assuming the manual is correct).

Am I forgetting to set something? I have whittled down the program & this is all it does right now.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

I was going totally nutty--tried everything, then gave up. I decided that since I wanted PA6 to generate an interrupt I might be able to rig up the analog comparator to generate one (it has this ability & happens to connect to PA6). Well upon figuring out how to set up ACSR I noticed that ACD must be SET to 1 to DISABLE the analog comparator (when active it overrides the pin change interrupt function). Since I never used the analog compartor, I assumed it was off & not interfering. As part of my massive test I had written a zero to this ACD bit to endure it was off (which is really "on" & is also the default).
Once I relaized that the defualt is "on" & off is a level 1, I went back & retried my pin change interrupt--IT WORKS!! Why couldn't the data sheet simply say write a 1 to ACD in ACSR to disable this override? Would have saved many hours!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!