Main Site Documentation

Interrupt in RLP


#1

Hi,

I use RLP on Hydra device. in fact I call to RLP (RLP light) from managed code and run RLP with endless loop.
In RLP I have main endless loop and few other function.

I want to be able to exit from RLP code when sending “trigger” on serial port I connected to Hydra.
I know how to use serial port on hydra, and in fact I want to use interrupt on



I have few questions:

1. How can I use interrupt on this register? Can I give interrupt handler to the interrupt so the handler will called when interrupt occurs? if you have example it will be great..

2. when I got the interrupt and the handler called - how can I exit from RLP to managed in that case without use flags and "return"? can I use some magics like exit() ?

3. for now I disabled all interrupt - how can I enable the above interrupt?

#2

I don’t know how to get an interrupt on a register.
But as long as RLP code is executed, no managed code is executed.
No timer, no thread, no nothing.
So I would recommend to setup the interrupt in an RLP call, the exit RLP.
Start your main loop in managed code.
On RLP interrupt raise an RLP event to managed code. (be aware that this has an undefined delay).

Alternatively you could go as follows:
start main loop in RLP.
Wait for interrupt in RLP (or poll the input)
When interrupt occurs, exit the main loop to go back to managed code.
Do managed stuff
Call RLP loop again

Running a loop in RLP would also have the disadvantage that you can not really debug anything.
For deploying you need to exit the RLP loop I think.
So you need to make some kind of delay after startup in managed code so the debugger can attach.


#3

I want to use Atmel CPU interrupt, not managed.


#4

I thought something like that.
This does not change what I wrote.
As long as RLP code is running, no managed code is executed.
Registering an interrupt and then return from RLP does not count as running RLP code.
As soon as the CPU interrupt is fired, managed code is stopped and RLP interrupt handler is executed. In there you can fire a managed RLP event.


#5

@ shm3 - unfortunately RLPLite does not have the same extensions are the premium RLP for handling interrupts. This means that you will need to vector the interrupt by writing the IRQ handler address to the Advanced Interrupt Controller (AIC) directly.

The routines for the AT91 (Hydra MCU) need to either be written in assembly at least for the prolog and epilog code, depending on the compiler you are using there are function modifiers that you could apply to support writing the routines in C, but they are compiler dependent.

Having said all of that, it is not quite that simple. The NETMF firmware already vectors the interrupt handlers and routes them through the NETMF plumbing, if you try vector the interrupts by bypassing the HAL implementation you will probably just hang the chip and need to reflash it.


#6

@ taylorza - I checked the firmware implementation for the AT91, the following is the driver for the AIC, this will probably be a good starting point for your adventures

DeviceCode\Targets\Native\AT91\DeviceCode\AT91_AIC\AT91_AIC.cpp

Not this is relative to the porting kit source code