You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/04.pro/boards/portenta-c33/tutorials/user-manual/content.md
+53-20Lines changed: 53 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -702,22 +702,37 @@ The Portenta C33 supports UART communication. The pins used in the Portenta C33
702
702
|`92`|`P603`|
703
703
|`93`|`P604`|
704
704
705
-
Please refer to the board pinout section of the user manual to find them on the board. The built-in ([Serial](https://www.arduino.cc/reference/en/language/functions/communication/serial/)) library functions can use the UART pins.
705
+
***Please refer to the board pinout section of the user manual to find them on the board. The built-in [Serial](https://www.arduino.cc/reference/en/language/functions/communication/serial/) library functions can use the UART pins.***
706
706
707
+
The `Arduino Renesas Core` has a built-in library that lets you use the UART communication, the `Serial` library, right out of the box. Let's walk through an example sketch demonstrating some of the module's capabilities.
707
708
708
-
To begin with UART communication, you'll need to configure it first. In the `setup()` function, set the baud rate (bits per second) for UART communication:
709
+
The example sketch below showcases how to configure the UART interface, read incoming data, and transmit data with the Portenta C33 board, which are common tasks for serial communication.
709
710
710
711
```arduino
711
-
// Start UART communication at 9600 baud
712
-
Serial.begin(9600);
713
-
```
712
+
/**
713
+
UART Communication
714
+
Name: UARTCommunication.ino
715
+
Purpose: This sketch demonstrates UART communication on the Portenta C33
714
716
715
-
To read incoming data, you can use a `while()` loop to continuously check for available data with the `Serial.available()` function and read individual characters with the `Serial.read()` function. The code shown above stores the incoming characters in a String variable and processes the data when a line-ending character is received:
717
+
@author Arduino Product Experience Team
718
+
@version 1.0 03/06/24
719
+
*/
720
+
721
+
// Include the necessary libraries for UART communication
722
+
#include <Arduino.h>
716
723
717
-
```arduino
718
724
// Variable for storing incoming data
719
725
String incoming = "";
720
726
727
+
void setup() {
728
+
// Initialize serial communication and wait up to 2.5 seconds for a connection
// Print a message to the Serial Monitor to indicate setup is complete
733
+
Serial.println("- UART communication setup complete!");
734
+
}
735
+
721
736
void loop() {
722
737
// Check for available data and read individual characters
723
738
while (Serial.available()) {
@@ -737,25 +752,44 @@ void loop() {
737
752
incoming += c;
738
753
}
739
754
}
755
+
756
+
// Example of transmitting data
757
+
// Transmit the string "Hello world!" every second
758
+
// Wait for 1 second before sending again
759
+
Serial.println("- Hello world!");
760
+
delay(1000);
740
761
}
741
-
```
742
762
743
-
To transmit data to another device via UART, you can use the `Serial.write()` function:
763
+
/**
764
+
Processes the received data
765
+
This function can be modified to perform different actions based on the received data
744
766
745
-
```arduino
746
-
// Transmit the string "Hello world!
747
-
Serial.write("Hello world!");
767
+
@param data The received data as a String
768
+
@return none
769
+
*/
770
+
void processData(String data) {
771
+
// Print the received data to the Arduino IDE Serial Monitor
772
+
Serial.println("- Received: " + data);
773
+
}
748
774
```
749
775
750
-
You can also use the `Serial.print()` and `Serial.println()` functions to send a String without a newline character or followed by a newline character:
776
+
Let's analyze the example sketch. First, the necessary configurations are made:
751
777
752
-
```arduino
753
-
// Transmit the string "Hello world!"
754
-
Serial.print("Hello world!");
778
+
- The UART communication is initialized at a baud rate of 115200.
779
+
- A loop continuously checks for available data and reads individual characters, storing them in a `String` variable.
780
+
- A newline character indicates the end of a message, triggering the processing function.
755
781
756
-
// Transmit the string "Hello world!" followed by a newline character
757
-
Serial.println("Hello world!");
758
-
```
782
+
The `processData()` function is called to process the received data. This example simply prints the data to the Arduino IDE's Serial Monitor. You can modify this function to perform different actions based on the received data. Finally, the example sketch shows how to send data using the `Serial.println()` function, which transmits the string `Hello world!` every second.
783
+
784
+
You should see the following output in the Arduino IDE's Serial Monitor:
785
+
786
+

787
+
788
+
You can also send information to the Portenta C33 using the Arduino IDE's Serial Monitor. In the `Message` box of the IDE's Serial Monitor, write a message (for example, `Portenta C33`) and press Enter; you should see the following output in the Arduino IDE's Serial Monitor:
789
+
790
+

791
+
792
+
You can download the example sketch [here](assets/UARTCommunication.zip).
759
793
760
794
### Wi-Fi®
761
795
@@ -1053,7 +1087,6 @@ void loop() {
1053
1087
}
1054
1088
```
1055
1089
1056
-
1057
1090
First, the necessary libraries are included:
1058
1091
1059
1092
- The `EthernetC33` library which contains the functionality required to communicate via Ethernet is included in the beginning.
0 commit comments