reversebias / mitosis

Firmware for nordic MCUs used in the Mitosis Keyboard
GNU General Public License v3.0
195 stars 125 forks source link

Change baud rate to 250k, which an 8Mhz pro micro can support. #10

Closed datagrok closed 2 years ago

datagrok commented 6 years ago

I recently built a Mitosis keyboard, but I used a 8Mhz pro micro instead of the 16Mhz one by mistake.

If I understood the datasheet correctly, when running at 8Mhz the pro micro can't achieve 1M baudrate.

I was able to make it work with no apparent loss in functionality by changing the baud rate to 250k.

Since this seems to be adequate, it could be set this way by default and enable either flavor of pro micro board to be compatible with the receiver module firmware.

A corresponding change is also needed in the qmk firmware, in keyboards/mitosis/config.h:

-#define SERIAL_UART_BAUD 1000000
+#define SERIAL_UART_BAUD 250000
reversebias commented 6 years ago

Hmm.. Might need to get the scope back out and test this one. I distinctly remember there being a reason for selecting the highest baud rate when I wrote it. Something to do with the polling time and buffers, IIRC. Did you just do a basic functionality test?

datagrok commented 6 years ago

Yes, just basic use of the keyboard. Also I'm an electronics novice and I don't own an oscilloscope so this was informed guesswork at best.

If you do find a problem I'd love it if you could describe it in more detail when you close this issue, so I can learn from the mistake. Thanks for the great project! 😄

joric commented 5 years ago

I upvote this. I've just managed to run receiver on a custom board with 3.3v promicro without regulators and level shifters and it was awesome. My project: https://github.com/joric/jorian

QMK Patch:

diff --git a/keyboards/mitosis/config.h b/keyboards/mitosis/config.h
index f2220278e..7abeae5bb 100644
--- a/keyboards/mitosis/config.h
+++ b/keyboards/mitosis/config.h
@@ -60,20 +60,20 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //#define NO_ACTION_FUNCTION

 //UART settings for communication with the RF microcontroller
-#define SERIAL_UART_BAUD 1000000
+#define SERIAL_UART_BAUD 250000
 #define SERIAL_UART_DATA UDR1

Mitosis receiver patch:

diff --git a/mitosis-receiver-basic/main.c b/mitosis-receiver-basic/main.c
index 5739d13..50df903 100644
--- a/mitosis-receiver-basic/main.c
+++ b/mitosis-receiver-basic/main.c
@@ -14,8 +14,20 @@
 #define UART_RX_BUF_SIZE 1                           /**< UART RX buffer size. */

+// I am using BlueMicro daughter board with 3.3V Pro Micro on top
+// See https://github.com/jpconstantineau/NRF52-Board/tree/master/YJ-14015
+// Picture: https://i.imgur.com/Ed3KmLV.jpg
+// CTS/RTS pins are never really used anywhere
+
+#define USE_BLUEMICRO
+#ifdef USE_BLUEMICRO 
+#define RX_PIN_NUMBER  14 //promicro TX0
+#define TX_PIN_NUMBER  13 //promicro RX1
+#else
 #define RX_PIN_NUMBER  25
 #define TX_PIN_NUMBER  24
+#endif
+
 #define CTS_PIN_NUMBER 23
 #define RTS_PIN_NUMBER 22
 #define HWFC           false
@@ -75,7 +87,7 @@ int main(void)
           CTS_PIN_NUMBER,
           APP_UART_FLOW_CONTROL_DISABLED,
           false,
-          UART_BAUDRATE_BAUDRATE_Baud1M
+          UART_BAUDRATE_BAUDRATE_Baud250000
       };

     APP_UART_FIFO_INIT(&comm_params,