??? 09/03/05 08:13 Read: times |
#100515 - Slight misconception. Responding to: ???'s previous message |
Russell Bull said: (my emphasis)
The core problem with your code is that the uart can only cope with one character at a time, Jeff Corr said:
You seemed to indicate in your message that the 8051 type uC is not well suited for receiving serial port data No, that's not what he meant at all! He's just telling you that you can't use it in the way you've tried to! Note that some UART chips - eg, the ones used in PCs - do have built-in FIFO buffers, but your average 8051 does not. Your average 8051's UART handles just one character at a time - and, therefore, so must your code. does anybody use it for this purpose? Absolutely! I've used up to four UARTs on a Triscend - all streaming serial data. Handling serial data on an 8051 is extremely common indeed. The way I understood it (correct me if I am wrong) but the serial port int is triggered when a char. is received. Correct so far. At this point, it would probably be helpful if you had chapter 3 of the "bible" open in front of you at page 11, and refer to figure 12 on page 12: Chapter 3 - 80C51 Family Hardware Description: http://www.semiconductors.philips.com/acrobat/v...WARE_1.pdf For simplicity, assume that nothing at all is happening on the transmit half of the 8051 UART... As the serial data bits are received, they are shifted into a shift register. When a complete byte has been received (start bit, 8 data bits, stop bit), it is copied from the shift register into SBUF, and RI is set. Upon jumping to the interupt, one char is received, the RI bit is set high... Not quite. As noted above, the RI bit is set by the hardware when the completed received byte is loaded into SBUF. If the serial interrupt is enabled, setting the RI bit causes an interrupt to occurr - and the processor jumps to the serial interrupt vector location. Again, this all happens in hardware. So, when your Interrupt Service Routine (ISR) is entered, you know that exactly one received byte is present in SBUF. Therefore, the job of your ISR is: and that's all it should do - this leaves the serial port ready for the next byte. When reception of the next byte is complete (and not before), SBUF will be loaded again, RI will be set again, and your ISR will be called again to retrieve another one byte. and the program should loop until then. The main program might loop - but the ISR certainly shouldn't! In fact, the whole point of using interrupt-driven serial IO is that the main program does not need to waste time looping while waiting for characters! That all assumed receive-only UART activity. In general, the UART ISR will be entered whenever RI (the receiver interrupt) or TI (the transmit interrupt) or both is set; therefore a general UART ISR has two sections - one checks RI, and handles the receive interrupt; the other checks TI, and handles the transmit interrupt. Hrm.. can an interupt be triggered from within itself? If RI is (still) set when the ISR exits, the processor will immediately jump straight back into the ISR! |
Topic | Author | Date |
Laser system serial port com | 01/01/70 00:00 | |
MHz? | 01/01/70 00:00 | |
11.059 | 01/01/70 00:00 | |
also... | 01/01/70 00:00 | |
Even more... anybody got any ideas? | 01/01/70 00:00 | |
Values in | 01/01/70 00:00 | |
text??? | 01/01/70 00:00 | |
thanks so far | 01/01/70 00:00 | |
Back to basics | 01/01/70 00:00 | |
Oh, come on... | 01/01/70 00:00 | |
"Program" or "Code?" | 01/01/70 00:00 | |
Oh dear... | 01/01/70 00:00 | |
Fundamental Comms Problem | 01/01/70 00:00 | |
Serial Code - Doomed! | 01/01/70 00:00 | |
this is getting ridiculous | 01/01/70 00:00 | |
learning process | 01/01/70 00:00 | |
oh well | 01/01/70 00:00 | |
agreed - waiting for the real stuff :-) | 01/01/70 00:00 | |
cart before horse | 01/01/70 00:00 | |
weekend approaching? | 01/01/70 00:00 | |
sure we can, but then why do you say the | 01/01/70 00:00 | |
this belong in the chat, but since it is | 01/01/70 00:00 | |
hrm | 01/01/70 00:00 | |
make an effort do not "whip up some code | 01/01/70 00:00 | |
facts & emotions | 01/01/70 00:00 | |
k | 01/01/70 00:00 | |
Good luck with the 430's | 01/01/70 00:00 | |
int | 01/01/70 00:00 | |
Slight misconception. | 01/01/70 00:00 | |
Next step | 01/01/70 00:00 | |
-1 provocative troll | 01/01/70 00:00 | |
read | 01/01/70 00:00 | |
which derivative? | 01/01/70 00:00 | |
dallas | 01/01/70 00:00 | |
DS89C420 | 01/01/70 00:00 | |
system im using | 01/01/70 00:00 | |
int | 01/01/70 00:00 | |
Process | 01/01/70 00:00 | |
Why do you persist | 01/01/70 00:00 | |
2 byte protocol | 01/01/70 00:00 | |
Intersting, but... | 01/01/70 00:00 | |
very interesting | 01/01/70 00:00 | |
How to proceed | 01/01/70 00:00 | |
a problem and a suggestion | 01/01/70 00:00 | |
Problems many & varied | 01/01/70 00:00 | |
Begin at the beginning! | 01/01/70 00:00 | |
started again | 01/01/70 00:00 | |
Re: started again | 01/01/70 00:00 | |
ah crap. | 01/01/70 00:00 | |
ah my eyes! | 01/01/70 00:00 | |
continued.. | 01/01/70 00:00 | |
Second UART | 01/01/70 00:00 | |
int vector | 01/01/70 00:00 | |
Look at the datasheet ! | 01/01/70 00:00 | |
yup | 01/01/70 00:00 | |
serial port 1 interrupt vector | 01/01/70 00:00 | |
okay | 01/01/70 00:00 | |
Still not OK | 01/01/70 00:00 | |
ISR reset | 01/01/70 00:00 | |
take rest | 01/01/70 00:00 | |
rest........ | 01/01/70 00:00 | |
STOP | 01/01/70 00:00 | |
just to be sure... | 01/01/70 00:00 | |
man int triggering | 01/01/70 00:00 | |
Craig, please remove this thread this is | 01/01/70 00:00 | |
Request | 01/01/70 00:00 | |
num | 01/01/70 00:00 | |
again | 01/01/70 00:00 | |
Thanks ALOT Jan !! | 01/01/70 00:00 | |
works, so now do the reading | 01/01/70 00:00 | |
serial port int | 01/01/70 00:00 | |
transmit | 01/01/70 00:00 | |
transmit | 01/01/70 00:00 | |
Oh dear | 01/01/70 00:00 | |
I dont give up. | 01/01/70 00:00 | |
er | 01/01/70 00:00 | |
brains? | 01/01/70 00:00 | |
Or lack thereof... | 01/01/70 00:00 | |
Persistance is a virtue | 01/01/70 00:00 | |
basics | 01/01/70 00:00 | |
updated | 01/01/70 00:00 | |
Solve i problem at a time | 01/01/70 00:00 | |
one more problem knocked down | 01/01/70 00:00 | |
PWM spoiled by Rx | 01/01/70 00:00 | |
lines![]() | 01/01/70 00:00 |