Sunday, September 17, 2006

On the edge

After much mental meanderings about how to register one button press as one interrupt with timers and whatever, I had a chat with my friend Andrew up in Seattle. He wrote the book on this sort of stuff (literally). He suggested configuring the external interrupt to trigger on edge rather than level. So one more line to add in the main setup code:

// External Interrupt Mode for EINT0 is Edge Sensitive
EXTMODE = EXTMODE | 1;

and it all works. One button one interrupt, one counter incremented.

If you add this line after the VICIntSelect and the line from the previous posting in the interrupt routine to the previous project here, it should all work for you. The full project will be added to the download area shortly. Meanwhile hack and enjoy!

1 Comments:

At 12:26 PM, Blogger Rod said...

Good point! When working in a simulated world things can behave too perfectly. What I will probably do once I have the button example integrated with the RTX kernel is change the push_button function code that waits for precisely 50 milliseconds via the swatch function (I wonder if there was an intentional pun in the name of that function) to something more realistic using the rand function in uVision to waggle the pin up and down for random amounts to time simulating a more noisy button press. I can then use an RTX timer to manage a sample and hold type scenario.

 

Post a Comment

<< Home