Hi, guys,
I'm trying to write a function for automatic USART initialization with parameter input of desired baud rate, F_CPU and the following options:
#define USART_OPT_ONE_STOP_BIT 0 #define USART_OPT_TWO_STOP_BITS 0x0008 #define USART_OPT_NO_PARITY 0 #define USART_OPT_EVEN_PARITY 0x0020 #define USART_OPT_ODD_PARITY 0x0030 #define USART_OPT_5_BITS_PER_CHAR 0 #define USART_OPT_6_BITS_PER_CHAR 0x0002 #define USART_OPT_7_BITS_PER_CHAR 0x0004 #define USART_OPT_8_BITS_PER_CHAR 0x0006 #define USART_OPT_9_BITS_PER_CHAR 0x0406 #define USART_OPT_ASYNC 0 #define USART_OPT_SYNC 0x0040 #define USART_OPT_SLAVE 0 #define USART_OPT_MASTER 0x0100 #define USART_OPT_POLARITY_0 0 #define USART_OPT_POLARITY_1 0x0001
Coz what I'm not sure about is that U2X=0 has higher Maximum Receiver Baud Rate Error tolerance than U2X=1,
so if a baud_rate value result in the same error rate for both normal speed and double speed, then I should choose normal speed. But if such ideal situation is not the case, then I need two weighting factors.
Any one have ideas?
Cheng