DoStuff Wiki
Attachments
History
Blame
View Source
Documentation
About An Otter Wiki
Toggle dark mode
Login
Home
A - Z
Changelog
Page Index
Hardware
Backplane
Board Features
Memory Map
News
20260512 - Increased Cpu Speed
Programming
Examples
Duart
PIT
Handling Interrupts
Machine Library
MMU
Reference Material
Runtime
Toolchains
Project Ideas
Operating System
Gloworm Port
Linux Port
Atari Vector Generator
Ethernet Card
Keyboard Controller
Monitor
BIOS
Books
Datasheets
Getting Connected
Home
Specs and Tech Notes
Programming
Handling Interrupts
d244ca
Commit
d244ca
2026-03-29 14:10:12
Bob Green
: -/-
programming/handling interrupts.md
..
@@ 17,3 17,63 @@
}
```
gcc knows that functions declared using either of the above methods should end with the `rte` rather than `rts` instruction.
+
+
## Example
+
```c
+
#include <stdio.h>
+
#include <machine.h>
+
+
#define LEDS1 0xa0
+
#define LEDS2 0x50
+
+
static unsigned int ticks = 0;
+
+
void twiddle_thumbs(void);
+
+
void ISR isr(void) {
+
ticks++;
+
+
*pit_tsr = 1;
+
}
+
+
void scan() {
+
static int lednum = 2;
+
static int delta = 1;
+
+
clear_led(lednum);
+
+
lednum += delta;
+
if ((lednum < 2) || (lednum > 7)) {
+
delta = -delta;
+
lednum += delta;
+
lednum += delta;
+
}
+
+
set_led(lednum);
+
}
+
+
int main(void) {
+
unsigned char ivr = *pit_tivr;
+
+
int loop = 0;
+
+
printf("Press any key...\n");
+
+
_pit_set_counter(1000);
+
*pit_tsr = 1;
+
+
set_isr_vector(ivr, isr);
+
+
while (!_char_available()) {
+
printf("%08x\r", ticks);
+
+
loop++;
+
if (loop == 100) {
+
scan();
+
loop = 0;
+
}
+
}
+
+
_getchar();
+
}
+
```
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9