Handling interrupt

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

Reply to
Marco
Loading thread data ...

key

A good idea!

Many Thanks Marco

Reply to
Marco

key

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

Reply to
Alexander Baranov

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.

Reply to
Dan

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

Reply to
Steve at fivetrees

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

Reply to
Steve at fivetrees

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.