Programming: Setting the Stop Bits and Data Bit Length (8-bits) for USART/UART Communication
Share
The stop bits are at the end of the data frame and signal the end of the that frame for the receiver. Setting for stop bits, use the USBS (UART Stop Bit Select) in the UCSRC (UART/USART Control and Status Register C)
UCSRC |= (1 << USBS); //Sets 2 stop bits UCSRC &= ~(1 << USBS); //clears the USBS for 1 stop bit, only needed if the bit was already set To set the number of data bit to use, the UCSZ0-2 (Character Size Bits) in the UCSRC register. Example: //Set data bit length is 8-bit UCSR0C |= (3 << UCSZ00);