-
Notifications
You must be signed in to change notification settings - Fork 0
/
my13_uart_m4_m7_print.ino
142 lines (95 loc) · 3.11 KB
/
my13_uart_m4_m7_print.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* my13_uart_m4_m7_print.ino For grabbing the Serial1 crash report generated by the Portenta H7
*
* Note: Other Arduino must be a 3Volt arduino!
* GND Portenta to GND other Arduino
* TX Portenta to RX other Arduino
* RX Portenta to TX other Arduino
*
* On Portenta H7 https://content.arduino.cc/assets/Pinout-PortentaH7_latest.png
* On Nano 33 BLE https://content.arduino.cc/assets/Pinout-NANOble_latest.png
* On Nano 33 IOT https://content.arduino.cc/assets/Pinout-NANO33IoT_latest.png
*
*
* You could just purchase a TTL USB cable with the three connections
*
* The Portenta M7 Core Serial.println("Hi"); // works fine
* The Portenta M7 Core Serial1.println("Hi"); // prints out as Serial1
*
* The Portenta M4 Core Serial.println("Hi"); // prints out as Serial1
* The Portenta M4 Core Serial1.println("Hi"); // prints out as Serial1
*
* Easier to just use _UART1_.println("Hi"); // from Both M4 and M7 prints to Serial1 on the UX,TX,GND pins
*
*
* The Portenta also sends crash information out on the UART TX and RX pins.
* This program allows you to load a running serial1 monitor on another 3.3V Arduino board
* I use the program putty to monitor it (radio button serial, find com port and speed 115200)
* use DOS or CMD command "mode" to find the correct port
*
* But you could also just use the regual serial monitor on the correct port
*
* Update
* #define Serial1 _UART1_ // This solves an issue with Serial1 on the M4 core
*
*
*/
#if defined (CORE_CM7) || defined (CORE_CM4) // the PortentaH7
#ifdef CORE_CM7 // Start M7 specific complete sketch
void setup() {
bootM4();
Serial.begin(115200);
Serial1.begin(115200);
}
void loop(){
Serial.println("M7 serial monitor");
delay(5);
Serial1.println("Hello from M7 using M7 Serial1");
delay(3000);
}
#endif // all the M7 core stuff
#ifdef CORE_CM4 // Start M4 core specific sketch
#define Serial1 _UART1_ // This solves an issue with Serial1 on the M4 core
void setup() {
Serial.begin(115200);
Serial1.begin(115200);
}
void loop(){
Serial.println("Hello from M4 using Serial");
delay(5);
Serial1.println("Hello from M4 using Serial1");
delay(2000);
}
#endif // all the M4 core stuff
#else // some 3.3V non-portenta Arduino such as the Nano 33 BLE or Nano 33 IOT or SeeduinoXIAO
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
Serial1.begin(115200);
//while(!Serial.available()){} // I don't like this but useful today.
//Serial.println("Hello from the other Arduino");
digitalWrite(LED_BUILTIN, HIGH); // flash on-board LED no matter grounding
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
if (Serial1.available()) { // If anything comes in Serial1 (pins 0 & 1) (check your board, RX13 Tx 14 on Portenta)
Serial.write(Serial1.read()); // read it and send it out Serial (USB)
}
}
#endif
/*
* lets crash the Portenta !
*
* long comment the above code and uncomment the below code
*
*/
/*
void setup() {
}
void loop() {
analogWrite(A5,128);
}
*/