Fix timer interrupt

This commit is contained in:
Jeremy Soller 2020-02-03 20:12:23 -07:00
parent c1fbbce805
commit c50632c1bf
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
5 changed files with 31 additions and 10 deletions

View File

@ -2,13 +2,6 @@
#include <arch/time.h> #include <arch/time.h>
void external_0(void) __interrupt(0) {}
// timer_0 is in time.c
void external_1(void) __interrupt(2) {}
void timer_1(void) __interrupt(3) {}
void serial(void) __interrupt(4) {}
void timer_2(void) __interrupt(5) {}
void arch_init(void) { void arch_init(void) {
// Disable interrupts // Disable interrupts
EA = 0; EA = 0;

View File

@ -7,11 +7,12 @@
static volatile uint32_t time_overflows = 0; static volatile uint32_t time_overflows = 0;
void timer_0(void) __interrupt(1) { void timer_0(void) __interrupt(1) {
// Stop timer
TR0 = 0;
time_overflows++; time_overflows++;
// Restart timer // Start timer
TR0 = 0;
TF0 = 0;
TH0 = 0xFD; TH0 = 0xFD;
TL0 = 0x01; TL0 = 0x01;
TR0 = 1; TR0 = 1;

View File

@ -19,6 +19,15 @@
#include <common/debug.h> #include <common/debug.h>
#include <common/macro.h> #include <common/macro.h>
void external_0(void) __interrupt(0) {}
// timer_0 is in time.c
void timer_0(void) __interrupt(1);
void external_1(void) __interrupt(2) {}
void timer_1(void) __interrupt(3) {}
void serial(void) __interrupt(4) {}
void timer_2(void) __interrupt(5) {}
uint8_t main_cycle = 0; uint8_t main_cycle = 0;
void init(void) { void init(void) {

View File

@ -20,6 +20,15 @@
#include <common/debug.h> #include <common/debug.h>
#include <common/macro.h> #include <common/macro.h>
void external_0(void) __interrupt(0) {}
// timer_0 is in time.c
void timer_0(void) __interrupt(1);
void external_1(void) __interrupt(2) {}
void timer_1(void) __interrupt(3) {}
void serial(void) __interrupt(4) {}
void timer_2(void) __interrupt(5) {}
uint8_t main_cycle = 0; uint8_t main_cycle = 0;
void init(void) { void init(void) {

View File

@ -20,6 +20,15 @@
#include <common/debug.h> #include <common/debug.h>
#include <common/macro.h> #include <common/macro.h>
void external_0(void) __interrupt(0) {}
// timer_0 is in time.c
void timer_0(void) __interrupt(1);
void external_1(void) __interrupt(2) {}
void timer_1(void) __interrupt(3) {}
void serial(void) __interrupt(4) {}
void timer_2(void) __interrupt(5) {}
uint8_t main_cycle = 0; uint8_t main_cycle = 0;
void init(void) { void init(void) {