This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

P89V51RD2 external interrupt disabling and enabling in c code

I am using P89V51RD2 and need some clarification on external interrupt.
I wrote a program for P89V51RD2 with DS1307 RTC, 3 push buttons and LCD display. The functionality is "clock". Normally, my main function displays clock with date and day in LCD read from RTC. whenever any of the key pressed, ext1 happens as my keys are connected to EXT1 through AND gate and connected to port pins as well to find which key is pressed. In ISR, I am setting a flag and disabling interrupt and exiting as I want ISR only when first time key is pressed. Then, in main program, I am checking the flag and jump to the function, where i can set hour and minutes for alarm. Using two of the keys, I can set the hour and minutes. third key is to save the alarm. Then in same function next, I have Time set code to change the time if required. after third key pressed, if hour or minutes changed, the same shall be updated to RTC and sets the flag as 3 and return to main. in main, enabling EXT1 based on flag == 3.

But, the problem is, program again jumps to ISR as soon EXT1 = 1 was made... why? I have configured EXT1 as edge-triggered when microcontroller starts. please clarify.

I have tested previously with the code for only alarm set function in the function. It worked without any problem. after adition of time setings, I am getting this issue. Further, I dont want to disable the interrupt by making EA = 0. As, I need external interrupt 0 and timer interrupt in mean time to do some other function when it occurs.

Please help me. Please let me know, if source code is required for debugging.

Advanced thanks.

Parents
  • I have hardware debounce circuit in my design and I have verified same. There is no miss trigger from the switch. So, here I hope problem was only with IE1 bit set.

    I now realize that the difference between a) with no problem and this with the IE0 reset needed is that you work with multiple button press.

    anyhow with the IE0 reset included you can omit the debounce circuit

    Erik

Reply
  • I have hardware debounce circuit in my design and I have verified same. There is no miss trigger from the switch. So, here I hope problem was only with IE1 bit set.

    I now realize that the difference between a) with no problem and this with the IE0 reset needed is that you work with multiple button press.

    anyhow with the IE0 reset included you can omit the debounce circuit

    Erik

Children