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!

Monday, September 11, 2006

Gamers Paradise

How long does your kid hold the buttons on his game station down?

What I see now when I run the code is that a whole lot of interrupts happen after I "Push my button" and then they stop. The main program continues to waggle the pin.

So while the button is pressed, interrupts happen. When the button is not pressed interrupts don't happen -- "Logical Captain".

This is Grrrreat! But I want to press the button once, take my finger off the button and something should happen. Not multiple somethings!

Also, if I double press the button something different should happen. But what is a double press?

This is not good, because in my time I've met CTOs, COOs and entrepreneurs who, when I say "Keyboard Driver for [insert British Z80/6502 based computer of your choice]" shrink at the memory.
I too went through the mill in the 80s doing games-related stuff and it isn't pretty.

I think when I trigger the first interrupt, I will initiate a timer routine that ,when counted down, re-enables the EXTINT with the magic rune:

EXTINT = EXTINT | 1; // Clear EINT0 to accept interrupts

Saturday, September 09, 2006

A step in the right direction

Looking at what happens to the VIC and External Interrupts panes, it's pretty obvious that the External Interrupt flag goes high and just stays there forever.

So, more pouring over the LPC user manual for me.

Turns out there was one step that wasn't in the timer example that relates to clearing external interrupts in the interrupt routine. The magic rune is:

EXTINT = EXTINT | 1; // Clear EINT0 to accept interrupts

So, if you put this in the pressed function in the example after:

VICVectAddr = 0; // Acknowledge Interrupt

the program will take interrupts while the button is pressed.

Progress!

Friday, September 08, 2006

Guide two gone live

Part two of the Four Steps article I've been working on as part of my day job, in tandem with the LogStick, went live today. Woo Hoo!

You can read it here.

Thursday, September 07, 2006

Interrupts Interrupts and yet more Interrupts

A final hack to the Timer Interrupt example and I put together the code for the button interrupt example. You can download it here. It doesn't work, though!

If you run up the example code, you will see that all is running very nicely until you "Push my Button", then all hell ensues... interrupts just keep on happening (the counter in the pressed routine shown in Watch pane #1 bottom middle just increments endlessly) and the main program doesn't get a chance to run (the blinking pin doesn't blink anymore). Oh bother! So near and yet so utterly interrupted.