i have seen some UART code implemented using BUFFER..... I have donE simple uart program using interrupt with lpc2148........ what is the advantage of using BUFFER
Shortly - less interrupts. You can setup the UART to generate an interrupt only if a number of characters (8, 14 etc.) have been received - not for every character.
What "buffer" are you referring to?
Some UARTs have a built-in buffer - commonly called a "FIFO" - which, as Tamir says, can have the advantage of reducing the number of interrupts.
Your own software can also make use of a "buffer" - meaning some temporary storage where received characers can be held until the application is ready to process them.
It is very common to use a so-called "Ring" or "Circular" buffer with a UART - there are examples here on the Keil site, and Google will tell you lots about them...
good Answer andy neil.....
i forgot to mention the buffer type........ it is software ring buffer ....... here in this example application they are using software interrupt also swi 8 & 9 ...... what is advantage by storing the data in a ring buffer.....
Advantage with a buffer?
That you don't need to react at the exact moment when a character is received. You may let your main loop do what it needs to do, and now and then check the buffer for received data.
Think about it. What is the difference between having to be home when the mailman comes, or having a post box and just have to check the box for received mail?
Without ringbuffer, and without a FIFO in the UART, you will lose characters if you don't pick up the last received character before the next character has been shifted into the UART.
Question four answered - Tick.
On the way to 100%
Sometimes, the name round-robin is also used for the ring buffers.
And the magic with a ring buffer is that data is never moved. Instead, the insert and remove positions are stepped in a circular way. Not needing to move the data when an entry is consumed means that both insert and remove operations are constant-time and not affected by the size of the buffer or the amount of data currently stored in the buffer.
Another advantage - having a separate insert and remove pointer means that one task (the inserting one) is owning and updating the insert position. Another task (the consumer) is updating the read position. This means that a ring buffer in many situations can insert and remove data without any locking primitives (in some part depending on atomicity for the given hw platform).
But all this - and more - can be found with a bit of Google usage.
But it's probably best not to use that term in your Googling: you will get plenty of hits with "ring buffer" and "circular buffer" - but "round-robin" will confuse the issue with lots of references to task schedulers...