#102627 - Tails86 - Fri Sep 15, 2006 7:47 pm
I have never worked with interrupts before. I have always been taught the basic concept of an interrupt, but I have no experience of programming one.
I decided to take a whack at it and tried programming a counter that went up every 100mS. I wrote this program, but all that shows up on the screen is a 0. This shows that it is going into the interrupt at least once.
I tried to use a global variable to count how many times the interrupt has been activated instead of using another timer as an overflow, but that still didnt work.
Am I setting up the interrupt right?
I decided to take a whack at it and tried programming a counter that went up every 100mS. I wrote this program, but all that shows up on the screen is a 0. This shows that it is going into the interrupt at least once.
I tried to use a global variable to count how many times the interrupt has been activated instead of using another timer as an overflow, but that still didnt work.
Am I setting up the interrupt right?
Code: |
#include <mygba.h>
MULTIBOOT #include "main.h" void outlights(void) { unsigned int interrupts = REG_IF; char str[20]; if(interrupts & INT_TIMER0) { unsigned int count=REG_TM1D; WaitVBlank(); DrawBox3(140,30,180,38,0x0000); sprintf(str,"%i",count); Print(140,30,str,0xFF0); } *(unsigned short *)0x03fffff8 |= interrupts; REG_IF = interrupts; } int main(void) { ham_Init(); REG_IME=0x00; REG_INTERUPT=(u32)outlights; REG_IE |= INT_TIMER0; REG_IME=0x01; REG_DISPCNT = (3 | BG2_ENABLE); //start timer, overflow every .1 seconds REG_TM0D=63898; REG_TM0CNT = TIMER_FREQUENCY_1024 | TIMER_ENABLE; REG_TM1CNT = TIMER_OVERFLOW | TIMER_ENABLE; while(true) { ; } return 0; } |