Handling interrupt

May 13, 2005 5 Replies

Hallo, I have made a microcontroller with keyboard (16 key).



I have a C function to handle interrupt that comes from keyboard when a key is pressed.



I should make a C software (not graphic) with a menu.



Every key must corresponds to a option of the menu and when I push one key the software must load the appropriate function.



In what way can be realized in C?



Thanks Marco


key

A good idea!

Many Thanks Marco

key

Maybe make an array of 16 pointers to appropriate functions? Regards, Alex.

a

That is the way we do it to. Just index the array of function pointers with a button number. Then all you have to change is the order of items in the array to change the buttons, simple and effective.

I'd be wary of doing major functional state changes in an interrupt. You might do better to set a flag, and have the top-level roundrobin pick up and act upon it.

Steve

formatting link

Really, that's all there is to it.

You'd be wise to consider the interrupt layer as a signalling layer. Leave all the major decisions to the top level. Communicate between the two with flags (specifically, semaphores).

Do you know what a round-robin is? (Briefly: it's top-level code that loops looking for changes, and acts upon them.)

Steve

formatting link

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required