- Permission to use, copy, modify, distribute, and sell this
+ Permission to use, copy, modify, distribute, and sell this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software without specific, written prior permission.
The author disclaim all warranties with regard to this
- /* Set reception timer compare period and enable compare ISR */
- OCR1A = BIT_TIME;
+ /* Set the transmission and reception timer compare values for the default baud rate */
+ SoftUART_SetBaud(9600);
+
+ /* Setup reception timer compare ISR */
-
- /* Reset the bit reception timer */
- TCNT1 = 0;
+
+ /* Reset the bit reception timer to -(1/2) of the total bit time, so that the first data bit is
+ * sampled mid way through the total bit time, making reception more robust.
+ */
+ TCNT1 = -(OCR1A >> 1);
/* Check to see that the pin is still low (prevents glitches from starting a frame reception) */
if (!(SRXPIN & (1 << SRX)))
/* Check to see that the pin is still low (prevents glitches from starting a frame reception) */
if (!(SRXPIN & (1 << SRX)))