CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / Language Constructs / Interrupts

Interrupts

The timer interrupt will cause an immediate branch to a specified line number or label (similar to a GOSUB). Return from an interrupt is via the IRETURN statement. All statements (including GOSUB/RETURN) can be used within an interrupt.

During processing of an interrupt all other interrupts are disabled until the interrupt routine returns with an IRETURN.

A periodic interrupt (or regular “tick”) with a period specified in milliseconds can be setup using the SETTICK statement. This interrupt has the lowest priority.

Interrupts can occur at any time but they are disabled during INPUT statements. If you need to get input from the keyboard while still accepting interrupts you should use the INKEY$ function. When using interrupts the main program is completely unaffected by the interrupt activity unless a variable used by the main program is changed during the interrupt.

For most programs MMBasic will respond to an interrupt in under 100µS. To prevent slowing the main program by too much an interrupt should be short and execute the IRETURN statement as soon as possible.

Also remember to disable an interrupt when you have finished needing it – background interrupts can cause strange and non-intuitive bugs.

All commands that use an interrupt (eg, SETTICK, ON KEY, etc) can specify a user defined subroutine an addition to a label or a line number. The interrupt subroutine will return control to the main program on an END SUB or EXIT SUB (ie, IRETURN should not be used in the subroutine).

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2025 · Generate Pro Theme on Genesis Framework · WordPress · Log in