Practical
Embedded Java

Writing an aJile ISR


A practical engineering approach to using embedded Java in real-world applications.


...



There are inefficiencies in the 3.16.09 aJile Event Handler framework which can cause events to be lost if there is sufficent other activity such as serial I/O. One solution is to write your own interrupt service routine (ISR).

As of 2005 June 20 Systronix has not yet implemented this. When we do, we will post a specific example here. If you want to share yours, please contact us, or better yet, post to the SystronixJava user group.


Custom ISR Template for aJile systems (JStamp, JStik, SaJe)
Get the template: CustomIsr.java The attached interrupt handler template still uses the GPIO driver but eliminates a method call that is used for GPIO event classes. Basically the GPIO driver determines which GPIO interrupt is pending and calls the "interruptEvent" method to notify a thread "mProcess" which is waiting to process the interrupt. This template will need to be applied for each GPIO interrupt you have in your system. The following updates need to be made to adapt this handler to your system:
  1. Change the class name "CustomIsr" and it's constructor to the name for your handler.
  2. Identify which GPIO port and bit # you use. The static string "GPIO_port_bit" is used to identify the GPIO port and bit #. (The template shows port A, bit 0).
  3. The priority of the thread processing the interrupt needs to be setup according to your system. The static "PROCESS_PRIORITY" is a JEM priority. (The template shows an arbitrary priority of 12)
  4. The interrupt condition needs to be specified for your system. You may have already used the method "setPinInterruptCondition" to specify this before. (The template shows an arbitrary setting of " FALLING_EDGE")
  5. The "mProcess" run method is setup to perform the processing. You will need to insert your interrupt processing code after the comment "Process the interrupt here!"
  6. Don't forget to include the GPIO driver for each port you use (configured in JEMBuilder).

You should realize that any interrupt that occurs is processed by an interrupt handler with interrupts disabled. Interrupts are not re-enabled until the interrupt handler completes and returns. During the execution of the interrupt handler, a higher priority interrupt may become pending but won't be acknowledged until the current interrupt handler completes. Therefore, interrupt handlers need to be as short as possible to minimize how long interrupts are disabled. Using the attached template will reduce the GPIO interrupt handling time.


 
Systronix® 939 Edison St, Salt Lake City, Utah, USA 84111
Tel +1-801-534-1017, Fax +1-801-534-1019
contact us     Time Zone: MDT (UTC-6)
 

Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Systronix is independent of Sun Microsystems, Inc.
TStik, JStik, JCX, JStamp, JSimm, JDroid, and JRealTime are trademarks of Systronix, Inc.
1-Wire, iButton and TINI are trademarks of Dallas Semiconductor
Simmstick is a trademark of Dontronics
LEGO® is a trademark of Lego A/S, Denmark