Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of APP1_customProtocole by
Diff: customUART.cpp
- Revision:
- 5:259661cbf9c3
- Child:
- 6:5c8e02d5ebcc
diff -r e6df056992c1 -r 259661cbf9c3 customUART.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/customUART.cpp Mon Jan 11 04:04:54 2016 +0000
@@ -0,0 +1,39 @@
+#include "customUART.h"
+
+CustomUART::CustomUART()
+{
+ //Choose the right pin for UART3 port (STEP5)
+ volatile int* PINSEL0 = (volatile int*)0x4002C000;
+ *PINSEL0 = *PINSEL0 | 0b10 | (0b10 << 2);
+
+ //Select the good clock to configure the baud rate (STEP2)
+ volatile int* PCLKSEL1 = (volatile int*)0x400FC1AC;
+ *PCLKSEL1 = *PCLKSEL1 | (0b01 << 18);
+
+ //Enable the UART3 port (STEP1)
+ volatile int* PCONP = (volatile int*)0x400FC0C4;
+ *PCONP = *PCONP | (0b1 << 25);
+
+ //Enable clock division to have good baud rate (STEP3)
+ volatile int* U3LCR = (volatile int*)0x4009C00C;
+ volatile int* U3DLL = (volatile int*)0x4009C000;
+ volatile int* U3DLM = (volatile int*)0x4009C004;
+
+ *U3LCR = *U3LCR | (0b1 << 7);
+ *U3DLM = 0x02;
+ *U3DLL = 0x71;
+ *U3LCR = 0b11;
+
+ //Enable the UART FIFO (STEP4)
+ volatile int* U3FCR = (volatile int*)0x4009C008;
+ *U3FCR = *U3FCR | 0b1;
+
+
+}
+
+void CustomUART::putc(const char caracter)
+{
+ volatile int* U3THR = (volatile int*)0x4009C000;
+ *U3THR = caracter;
+}
+
\ No newline at end of file
