Handling interrupt

M

Marco

Hallo,
I have made a microcontroller with keyboard (16 key).
I have a function to handle interrupt that comes from keyboard when a key is
pressed.

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

I thought to make into main.c a cicle like this:

while (1)
interrupt_handler


"interrupt_handler" is a function that handles interrupt and tell which key
was pressed.

It contains also a "switch case... case... case..."

where I have assigned a function to every key.

Is it correct?

Thanks
Marco
 
M

Marco

I would know if, when the processor is executing a function called from
"switch case" and I press a key, it stops executing code and read the
function "interrupt_handler" ???
 
J

Jens.Toerring

Marco said:
I have made a microcontroller with keyboard (16 key).
I have a function to handle interrupt that comes from keyboard when a key is
pressed.
I should make a C software (not graphic) with a menu.
I thought to make into main.c a cicle like this:
while (1)
interrupt_handler
"interrupt_handler" is a function that handles interrupt and tell which key
was pressed.
It contains also a "switch case... case... case..."
where I have assigned a function to every key.
Is it correct?

First of all, this isn't really on-topic here in clc, I guess the
newsgroup comp.arch.embedded would be more appropriate. Moreover,
interrupts by their very nature are asynchronous, so they usually
aren't dealt with in a tight loop (maybe unless your program is
supposed to go into the ROM or whatever of the microcontroller of
the keyboard) but there typically are some ways to install handlers
for them (e.g. in a table of function addresses for each possible
interrupt). These get invoked automatically once an interrupt hap-
pens, interrupting the normal flow of the program and for example
pushing information about the newly pressed (or released) key into
some system-internal structure, from where it can be fetched by the
program (either directly or by nicely asking the OS). Of course, how
all of this is done is extremely system dependent and has hardly
anything to do with the language C, which is the topic of this news-
group, so I stop here right now;-)

Regards, Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top