We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
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
When you do SBUF=0 the UART will transmit the zero then set TI once it is ready to accept another character for transmission. The time between writing to SBUF and TI being set will depend on the baudrate you are using. I don't think you really want to transmit a zero - there is no need to 'reset' SBUF. Stefan