summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-10-26 16:03:45 +0100
committerMichael Buesch <mb@bu3sch.de>2008-10-26 16:03:45 +0100
commite577f0bf8fb839698a15dcd3464cfb83fa941a03 (patch)
tree68861da7cca4e813a28ac40b84f0ec0853e785d6 /pressure_control/firmware
parent435efeb81d6942cb2bfde17fbab8b4207371192b (diff)
downloadcnc-e577f0bf8fb839698a15dcd3464cfb83fa941a03.tar.xz
cnc-e577f0bf8fb839698a15dcd3464cfb83fa941a03.zip
pressure_control: Use UART rate with less error
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'pressure_control/firmware')
-rw-r--r--pressure_control/firmware/remote.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/pressure_control/firmware/remote.c b/pressure_control/firmware/remote.c
index 29b15b4..be360e5 100644
--- a/pressure_control/firmware/remote.c
+++ b/pressure_control/firmware/remote.c
@@ -29,7 +29,8 @@
#include <avr/io.h>
-#define BAUDRATE 115200
+#define BAUDRATE 38400 /* Error = 0.2% */
+#define USE_2X 0
static struct remote_message rx_msg;
@@ -329,14 +330,22 @@ void remote_pressure_change_notification(uint16_t mbar,
send_message(&msg);
}
+#if USE_2X
+# define UBRR_FACTOR 2
+#else
+# define UBRR_FACTOR 1
+#endif
+
static void usart_init(void)
{
uint8_t dummy;
/* Set baud rate */
- UBRRL = lo8((CPU_HZ / 16 / BAUDRATE) * 2);
- UBRRH = hi8((CPU_HZ / 16 / BAUDRATE) * 2) & ~(1 << URSEL);
+ UBRRL = lo8((CPU_HZ / 16 / BAUDRATE) * UBRR_FACTOR);
+ UBRRH = hi8((CPU_HZ / 16 / BAUDRATE) * UBRR_FACTOR) & ~(1 << URSEL);
+#if USE_2X
UCSRA = (1 << U2X);
+#endif
/* 8 Data bits, 1 Stop bit, No parity */
UCSRC = (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
/* Enable transceiver and RX IRQs */
bues.ch cgit interface