??? 12/12/10 20:11 Read: times |
#180099 - Using Interrupts to call functions |
So I'm in a pickle. I'm trying to use Timer Interrupts to call functions. For the first instance, the interrupt will work and jump the program to the next function. After that, all the timers stop working. I can't figure out why this is happening.
Here is the break down: The Program is designed to create a waveform on the speaker. When the Mode_Button is pressed, the note is to change. What I get instead is the interrupts, and timers stop working. I can make other buttons do other things, but all timers are dead. Below is a basic "working" code of what I have in mind. Thanks for your help. #include<reg932.h> sbit SPEAKER = P1^7; sbit Mode_Button = P2^3; int check; int n; int m; void Mode1(); void Mode2(); void Mode3(); void timer0() interrupt 1 { if(Mode_Button == 0) { check++; if(check == 0) Mode1(); if(check == 1) Mode2(); if(check == 3) Mode3(); } else { SPEAKER = ~SPEAKER; TH0 = n; TL0 = m; TF0 = 0; } } void main() { P2M1 = 0x00; P1M1 = 0x00; TMOD = 0x01; EA = 1; ET0 = 1; TH0 = 0xFD; TL0 = 0x92; TR0 = 1; check = 0; Mode1(); } void Mode1() { while(1) { n = 0xFD; m = 0x92; } } void Mode2() { while(1) { n = 0xFD; m = 0xD5; } } void Mode3() { while(1) { n = 0xFD; m = 0xF4; } } |
Topic | Author | Date |
Using Interrupts to call functions | 01/01/70 00:00 | |
what is Your target? | 01/01/70 00:00 | |
Responding to: Stefan Kanev's previous message | 01/01/70 00:00 | |
big task | 01/01/70 00:00 | |
The next question | 01/01/70 00:00 | |
flags, semaphors and so on | 01/01/70 00:00 | |
Endless loops | 01/01/70 00:00 | |
main | 01/01/70 00:00 |