EmbDev.net

Forum: ARM programming with GCC/GNU tools any procedures in ISR - is it possible?


Author: gregor (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi everybody,

Is it possible to use an procedures/functions inside interrupt service
routine?  What should I add/change in armVIC files in this case? When I
try to use some LCD procedure in ISR my program doesn`t want to start. I
use LPC2138 uC.

Thanks in advance
gregor

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
gregor wrote:
> Hi everybody,
>
> Is it possible to use an procedures/functions inside interrupt service
> routine?  What should I add/change in armVIC files in this case? When I
> try to use some LCD procedure in ISR my program doesn`t want to start. I
> use LPC2138 uC.
>
> Thanks in advance
> gregor

In general functions called from ISRs must be reenterant(unless they are
never called from anywhere else), and must not block - for example
calling printf() from an ISR is usually a bad idea for several reasons:
If the buffer is full, the function will not return until it becomes
empty, which it will never do if the UART interrupt is a lower priority
or if interrupts are switched off.

Systems usually switch to a different (and usually smaller) stack in the
interrupt context, so you need to be careful about stack (local
variable, and call depth) usage. Again using printf as an example, it
has a particularly large stack requirement and may crash an interrupt
routine.

So to answer your question it is probably a problem with nature of the
function you are calling. Another possibility is that you are installing
and enabling the ISR before the hardware is properly initialised. Before
enabling any interrupt it is usually important to clear any pending
interrupt before hand otherwise the ISR will be called immediatly. I
would be surprised if this was a simple 'configuration' problem, it is
more likely te be a fault with your code.


Clifford

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.