??? 12/20/06 09:55 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#129810 - More... Responding to: ???'s previous message |
As Neil explains - you cannot do both.
You can choose to use interrupts or you can poll - not both. without interrupts mov SBUF,a clr TI jnb TI,$ this will send the char and wait for it to complete. Of course, the cpu is tied up doing this whilst the character is being sent (~1mS at 9600 baud). Obviously not efficient. Using interrupts gets a little more complex. Usually the interrupt would read the data to be sent from a circular buffer of just a simple buffer. Your main code would put the required data in the buffer and signal the interrupt code to send it. Similarly you could do the reverse for the receive interrupt - it reads the SBUF and places the character into a memory buffer. The idea of using interrupts is that when an event occurs (transmitter empty), we jump to the isr and it grabs the next char to send, shoves it into SBUF and does a RETI. Thus the cpu is free to do other things in the meantime. Much more efficient. You need to share variables between the main code and the isr in order to communicate between the two. Herein lies the complexity. Have a look at sample code to get the gist of this. You need to save the PSW and sometimes the ACC, the restore these before you RETI. I'll leave the rest for you to ponder. Using the carry bit to communicate status between the isr and main code is bad practice - just about anything can modify the carry flag! There's plenty of ram in the 8051 to use for this purpose. Why is using NOPS shaky and not portable? We're talking assembler here - portability doesn't enter the discussion! If you want portability, use 'c'. (yeh, I know Erik!!) |
Topic | Author | Date |
the nature of the UART/steping through interrupts | 01/01/70 00:00 | |
Uart is full duplex | 01/01/70 00:00 | |
Thanks Russell | 01/01/70 00:00 | |
UART Question Part 2 | 01/01/70 00:00 | |
You can not do both | 01/01/70 00:00 | |
In response to Neil | 01/01/70 00:00 | |
go with the bit | 01/01/70 00:00 | |
In response to Neil | 01/01/70 00:00 | |
In response to Neil | 01/01/70 00:00 | |
Sorry for teh tripple post... | 01/01/70 00:00 | |
More... | 01/01/70 00:00 | |
Search and Read | 01/01/70 00:00 | |
Thanks Russell | 01/01/70 00:00 | |
I hope Russell did not lead you down the garden pa | 01/01/70 00:00 | |
Erik - garden path indeed! | 01/01/70 00:00 | |
I'm using interrupts | 01/01/70 00:00 | |
Question about my interrupt driven UART | 01/01/70 00:00 | |
You know the answer. | 01/01/70 00:00 | |
Thanks Russell | 01/01/70 00:00 | |
answer is partially incorrect![]() | 01/01/70 00:00 | |
Can't single step on UART | 01/01/70 00:00 |