strange interrupt behaviour

Hopefully someone can give me a tip. I'm completely lost on what's happening.

I have the following problem. Using a 87C51RC processor I'm using 2 timers with interrupt, Serial comm with interrupt and the PCA timer with interrupt.
The problem is that, while there is no code which generates a serial interrupt (nothing is written to SBUF) the TI flag is set after the Timer0 interrupt has been processed. In other words, after a Timer0 interrupt the TI flag is set for no apparent reason. I read after doing a search on the forum that sometimes a timing issue can cause a problem. after building several loops to reduce speed, and reducing the level of optimization. I still have no idea where to look. I would greatly appreciate any help on this issue. I am using:
C51 Ver. 7.01
BL51 Ver. 5.01
uVision2 Ver 2.31

Kind regards
John Garrelts

Parents
  • I think I found the problem. It had nothing to do with Timer0. After disenabling Timer0 I still had the same error. What I expect was happening is the following.
    When initializing all the variables I reset SBUF to 0 followed by TI = 0 and ES = 0. so I expected that I would not get a TI flag. I think that the TI = 0 command was too close to the SBUF = 0 command. I altered the code so that there was a (big) delay between SBUF = 0 and TI = 0. and no more problems. Does anyone know how much time it takes before a flag is set?
    I've found a solution for my problem but I still not quite understand it.

    Regards

    John Garrelts

Reply
  • I think I found the problem. It had nothing to do with Timer0. After disenabling Timer0 I still had the same error. What I expect was happening is the following.
    When initializing all the variables I reset SBUF to 0 followed by TI = 0 and ES = 0. so I expected that I would not get a TI flag. I think that the TI = 0 command was too close to the SBUF = 0 command. I altered the code so that there was a (big) delay between SBUF = 0 and TI = 0. and no more problems. Does anyone know how much time it takes before a flag is set?
    I've found a solution for my problem but I still not quite understand it.

    Regards

    John Garrelts

Children
More questions in this forum