??? 03/07/04 16:01 Read: times |
#66186 - RE: Is this okay Responding to: ???'s previous message |
I would say, as far as I can see it would probably work, although it is still a crude solution. But if you are a beginner, there is nothing to be ashamed of. There is one thing however I would certainly put in:
You have enabled the receiver in your code with this line: 'MOV SCON,#50H ;8 bit data mode with 1 start and stop bit and receive enable' (I haven't checked it, but if you say you have enabled the receiver, I will assume that to be true) That means that you CAN also get a serial interrupt if a character is received, not only if one is transmitted. If that possibility exists, your code MUST test if the serial interrupt was because the transmitter is ready to send, or because the receiver received a new byte. So in stead of SERIAL: JB TI,CLEAR CLEAR: CLR TI (and the test is not necessary because you will end up at CLEAR if the test fails too...) You could do it like this: SERIAL: JBC TI,Transmit JBC RI,Receive ;If a serial interrupt happened, one of these WILL be executed. Transmit: .... reti Receive: .... reti Put something like this in, OR don't enable the receiver. Don't worry, take it one step at a time! Try what you have just written, I think you will find that it works. If your requirement is to be able to send the same string of three characters every time, it will probably fulfill it. It is better than jnb flag,$ already. |