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

Problem in Interrupt

I have a strange problem in interrupt, I am incrementing a variable in interrupt and displayng in main program, the code is working fine for some time , latter the system gets hanged , i dont know why??

if there is any solution to this problem plz let me know, I am using Silabs C8051F120

int var=0;
        void PCA_Timer_Interrupt(void) interrupt 9 using 2
         {
                 var++;
          }


       void main()

{
          sprintf(buffer,"%d",(int)var);
          display(buffer,LINE1);

}



Parents
  • "found that this thread is already talking about the interrupt problem in Nordic nrf24e1"

    The Nordic chip is never mentioned in this thread. You should really open a new thread to discuss your problem. If not for netiquette, to show others that your problem is not the old problem already discussed in the thread.

    One note regarding using 0: when you declare a interrupt function specifying using N, the interrupt entry code assumes that the declared bank is 'set aside' for the interrupt, and does not preserve any used registers. So, if you declare using 0 and your program uses bank 0 for anything else, your interrupt will overwrite main program registers, and if you're lucky your program will crash. If you're out of luck, the program may actually run with some weird side effect.

    The using directive should only be used for ISRs that are at the same priority level, and that don't call any functions that are declared with other banked domains.

Reply
  • "found that this thread is already talking about the interrupt problem in Nordic nrf24e1"

    The Nordic chip is never mentioned in this thread. You should really open a new thread to discuss your problem. If not for netiquette, to show others that your problem is not the old problem already discussed in the thread.

    One note regarding using 0: when you declare a interrupt function specifying using N, the interrupt entry code assumes that the declared bank is 'set aside' for the interrupt, and does not preserve any used registers. So, if you declare using 0 and your program uses bank 0 for anything else, your interrupt will overwrite main program registers, and if you're lucky your program will crash. If you're out of luck, the program may actually run with some weird side effect.

    The using directive should only be used for ISRs that are at the same priority level, and that don't call any functions that are declared with other banked domains.

Children
No data