Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/31/05 17:47
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#94158 - RE: interrupt driven serial
Responding to: ???'s previous message
"i am not transmitting anything,"

Well of course YOU are not, the controller is! :-) But it does so because your program does not do what you think it will do. And that is the result of you not properly understanding the concept of interrupts, why they happen, and where ISR's come in.
An ISR is just another piece of program, and the serial ISR will be executed every time after the UART HARDWARE has completed sending out the previous byte. Regardless of what you are doing in main. The break is irrelevant (and unelegant, but that aside).

"why does the TIE flag is set, " (I suppose you mean the TI flag)

The TI flag gets set by the UART hardware after it has sent out the byte you last put in SBUF completely. You should NOT set TI to 1 yourself. Leave that to the hardware! The idea behind interrupt driven serial transmission is this:

In the main:

- Prepare a set of bytes you want to send, for instance like you do in an array, but for serious applications fifo's are used,
- Put the first byte in SBUF,
- Go and do other things.

That's all.

Now, while your main is doing something completely else, after the UART hardware has sent out the byte you put in SBUF, it will set TI.

If you have an ISR in place which does this:

- Check if there are more bytes to be sent, if not return from interrupt immediately.
- Put the next byte in SBUF and return from interrupt.

The transmitter will send all the bytes in the array and stop there.

So what you need to change:
- Do NOT set TI (before your for(;;) line) manually!
- The for(;;) loop you so unelegantly break out of is not necessary. All you need to have is i=1 and SBUF=array[1] to start the transmission, the rest will be handled by your ISR. This is the beauty of interrupt driven serial communication.
- Make your ISR so that it wil make TI=0, increase i, and if i<11 SBUF=array[i].

The fact that you attempt to start the transmission by setting TI manually indicates that you are wrong in your understanding of serial interrupts. I suggest you visit the tutorials on this site, read the 8051 'bible' (look in the links section on this site) and study some good examples.


List of 10 messages in thread
TopicAuthorDate
inetrrupt driven serial            01/01/70 00:00      
   RE: inetrrupt driven serial            01/01/70 00:00      
      interrupt driven serial            01/01/70 00:00      
         It means Done            01/01/70 00:00      
         RE: interrupt driven serial            01/01/70 00:00      
            one of ways            01/01/70 00:00      
            thanks to all            01/01/70 00:00      
               RE: thanks to all            01/01/70 00:00      
   Wheel re-invention award            01/01/70 00:00      
      good subject !            01/01/70 00:00      

Back to Subject List