Commits

Trammell Hudson committed dc46da0

baud rate adjustments, but it turns out to be a mechanical problem

  • Participants
  • Parent commits dae33bb

Comments (0)

Files changed (1)

 /**
  * \file 45 baud sync teletype interface
  *
- * Uses a boost converter to make the 50-100V for driving the ciol.
+ * Uses a boost converter to make the 50-100V for driving the coil.
  * Test string:
  * now is the time for all good men to come to the aid of their country
  * the quick brown fox jumps over the lazy dogs
+ * abcdefghijklmnopqrstuvwxyz
+ * ryryryryryryryryryryryryry
+ * y becomes q or x
+ * r becomes g (rarely)
+ * cvcvcvcvcvcvcvcvcvcvcvcvcvcv
+ * 
  *
  * At 2 MHz the 45.45 baud (22ms) can be generated with the clock.
  */
 )
 {
 #ifdef CONFIG_UART
-	while (bit_is_clear(UCSR1A, UDRE1))
+	// The UART has 5N1 configured; we add a half stop
+	sbi(UCSR1A, TXC1);
+	UDR1 = c;
+	while (bit_is_clear(UCSR1A, TXC1))
 		;
-	UDR1 = c;
+	_delay_us(BIT_CLOCK/2);
+/*
+	_delay_us(BIT_CLOCK);
+	_delay_us(BIT_CLOCK);
+	_delay_us(BIT_CLOCK);
+	_delay_us(BIT_CLOCK);
+	_delay_us(BIT_CLOCK);
+*/
 #else
 	uint8_t ocr_one = OCR1C;
 	uint8_t ocr_zero = OCR1C;
 
 
 static void
+ubrr_adjust(
+	int delta
+)
+{
+	UBRR1 += delta;
+
+	char buf[] = {
+		hexdigit(UBRR1 >> 12),
+		hexdigit(UBRR1 >>  8),
+		hexdigit(UBRR1 >>  4),
+		hexdigit(UBRR1 >>  0),
+		'\r',
+		'\n'
+	};
+
+	usb_serial_write(buf, sizeof(buf));
+}
+
+// ckckckckckckckckckckckckckckckck
+static void
 boost_adjust(
 	int delta
 )
 		| (0 << UCSZ12) // 5 data bits
 		| (0 << UCSZ11)
 		| (0 << UCSZ10)
-		| (1 << USBS1) // 2 stop bits
+		| (0 << USBS1) // 1 stop bit; we will make a separate half stop
+		//| (1 << USBS1) // 2 stop bits
 		;
 #endif
 
 		{
 			boost_adjust(-10);
 			continue;
+		} else
+		if (c == '[')
+		{
+			ubrr_adjust(-10);
+			continue;
+		} else
+		if (c == ']')
+		{
+			ubrr_adjust(+10);
+			continue;
 		}
 
 		out(0xD6, 1);