RyanHan
Junior Member level 3
Dear Expert,
I had write a keil C code for my DS89C450 microcontroller. I had 2 interrupt. One of which is the external interrupt 3 tie to a hardware switch. And Timer interrupt 0. I am using Keil C to program this 2 interrupt. My problem is that once the hardware interrupt triggered by the switch, the timer interrupt stop functioning. I had did some troubeshooting and found that.
The purpose of my code is to wait for the switch to be pressed and interrupt the uC. After which, at regular interval, by timer interrupt, I will read the value of Port 0 and put into a buffer. Once a certain amount of byte was written, I will stop the timer interrupt and exist the external interrupt loop. Below is my program. Is it a good way to put a while loop in to external interrupt? Cause my problem now is that inside the external interrupt loop, my timer interrupt cannot work any more. I had check and both are of the same interrupt priority. Can any expert enlighten me as to what had went wrong with this code that the timer interrupt doesnt work once the external interrupt 3 trigger. Thanks a lot
I had write a keil C code for my DS89C450 microcontroller. I had 2 interrupt. One of which is the external interrupt 3 tie to a hardware switch. And Timer interrupt 0. I am using Keil C to program this 2 interrupt. My problem is that once the hardware interrupt triggered by the switch, the timer interrupt stop functioning. I had did some troubeshooting and found that.
The purpose of my code is to wait for the switch to be pressed and interrupt the uC. After which, at regular interval, by timer interrupt, I will read the value of Port 0 and put into a buffer. Once a certain amount of byte was written, I will stop the timer interrupt and exist the external interrupt loop. Below is my program. Is it a good way to put a while loop in to external interrupt? Cause my problem now is that inside the external interrupt loop, my timer interrupt cannot work any more. I had check and both are of the same interrupt priority. Can any expert enlighten me as to what had went wrong with this code that the timer interrupt doesnt work once the external interrupt 3 trigger. Thanks a lot
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 #include <DS89C4xx.h> unsigned int bytecounter, Read_data; void Int3(void) interrupt 9 { EIE = 0x00; TH0 = 0xE6; TL0 = 0xFF; TR0 = 1; while(!Read_data); TR0 = 0; EIE = 0x02; } void Timer0Interrupt(void) interrupt 1 { unsigned char buffer; . . . . . if (bytecounter > 10) Read_data = 1; } } void main (void) { IE = 0x82; EIE = 0x02; TMOD = 0x21; TH1 = 0xFD; SCON0 = 0x50; //for serial port communication TR1 = 1; while(1) { if (Read_data) { . . . . Read_Data = 0; } } }
Last edited by a moderator: