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

Timer

I am having a problem with my I2C. I am using a 89C664 philips microcontroller. I have two of these chips talking to each other. I have my I2C implemented in such a way that if the state (S1STA) doesn't match the correct value, my program will just keep waiting. Since this only happen very rarely, I want to implement a timer so it will automatically be forced out of the subrountine after one or two second. The question can I implement this within an interrupt, because my I2C is called based on interrupt. Also, how would I implement this timer. I am new to this, so any help would be greatly appreciated. The whole point of this is so my chip can resend the data or receive the data again if I2C failed.

thanks
Tommy

Parents
  • I think that you can use an interrupt in an ohter interrupt sub-routine without any trouble!

    In general each time your program get to interrupt sub-routine, programs disable all the interrupt requests. In your case, don't disable all interrupts. Just stay activated your timer interrupt.

    You just need to configure your Timer during the init of your program. And when your program jump to your interrupt sub-routine, launch the timer for 1 or 2 sec as you say. Stop it when your program left the sub-routine.

    If the program branch to timer sub-routine during the I2C interrupt sub-routine, do what is needed to left your I2C sub-routine

Reply
  • I think that you can use an interrupt in an ohter interrupt sub-routine without any trouble!

    In general each time your program get to interrupt sub-routine, programs disable all the interrupt requests. In your case, don't disable all interrupts. Just stay activated your timer interrupt.

    You just need to configure your Timer during the init of your program. And when your program jump to your interrupt sub-routine, launch the timer for 1 or 2 sec as you say. Stop it when your program left the sub-routine.

    If the program branch to timer sub-routine during the I2C interrupt sub-routine, do what is needed to left your I2C sub-routine

Children