Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
titleListing - Fast ISRs with µC/OS-III
linenumberstrue
          MyShortISR:                                                      (1) 
              Save enough registers as needed by the ISR;                  (2) 
              Clear interrupting device;                                   (3) 
              DO NOT re-enable interrupts;                                 (4) 
              Call user ISR;                                               (5) 
              Restore the saved CPU registers;                             (6) 
              Return from interrupt;                                       (7) 


Code Blockpanel

(1) As

mentioned

above,

an

ISR

is

typically

written

in

assembly

language. MyShortISR corresponds

to

the

name

of

the

handler

that

will

handle

the

interrupting

device.

(2) Here,

you

save

sufficient

registers

as

required

to

handle

the

ISR.

(3) The

user

probably

needs

to

clear

the

interrupting

device

to

prevent

it

from

generating

the

same

interrupt

once

the

ISR

returns.

(4) Do

not re-enable

interrupts

at

this

point

since

another

interrupt

could

make

µC/OS-III

calls,

forcing

a

context

switch

to

a

higher-priority

task.

This

means

that

the

above

ISR

would

complete,

but

at

a

much

later

time

and,

possible

cause

other

complications.

(5) Now

you

can

take

care

of

the

interrupting

device

in

assembly

language

or

call

a

C

function,

if

necessary.

(6) Once

finished,

simply

restore

the

saved

CPU

registers.

(7) Perform

a

return

from

interrupt

to

resume

the

interrupted

task.