Hi,
This is an interesting issue considering the serial port communication applications in Atmel AVR Processors.
I am using currently Procyon AVRlib C-Language Function Library for Atmel AVR Processors to write application over Atmel Mega2560.
The library has Dual UART driver with buffer support. ( uart.c / uart.h ) files. We can set the speed of the port. Good J When a new data is received, it receives a hardware rx interrupt and the interrupt routine puts the new data in buffer. Right. Up to this point, there is no problem.
What if we have a protocol that uses 1 start bit , 8 data bits , 1 stop bit and even parity ? This makes it difficult to imagine in byte structured buffers used in the library. Does this library handle the start, stop and parity bits, I didn't come up with these.
So, the only option is to write extra routines into the library. But can anyone give me information about the followings :
1 ) Does Procyon AVRlib handle the start, stop and parity bits of the serial communication protocol ?2 ) If not, what will we have in the buffer (lets say, buffer size is
10 bytes) after receiving a data stream like this :1 st Data Byte : StartBit - DATA - Parity Bit - StopBit 1 - 10101010 - 1 - 0
2 nd Data Byte : 1 - 10101010 - 1 - 03 rd Data Byte : 1 - 10101010 - 1 - 0
Will the the last bits of the 1 st data byte go into the 2 nd byte of the buffer? If so, do the first couple of bits go into the last bit portions of 2 nd byte of the buffer ? And so on...
Or should I implement the protocol handling in the rx / tx hardware interrupts?
Anyone got the idea?
B. Erbil KONUK