EmbDev.net

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


von gregor (Guest)


Rate this post
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

von Clifford S. (clifford)


Rate this post
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.