Skip to content

Commit fedd30a

Browse files
committed
Content update (UART section)
1 parent 9b12cdd commit fedd30a

File tree

1 file changed

+19
-1
lines changed
  • content/hardware/04.pro/boards/portenta-c33/tutorials/user-manual

1 file changed

+19
-1
lines changed

content/hardware/04.pro/boards/portenta-c33/tutorials/user-manual/content.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ The Portenta C33 supports UART communication. The pins used in the Portenta C33
704704

705705
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.
706706

707+
#### UART Initialization
707708

708709
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:
709710

@@ -712,12 +713,21 @@ To begin with UART communication, you'll need to configure it first. In the `set
712713
Serial.begin(9600);
713714
```
714715

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:
716+
#### Receive Data
717+
718+
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.
719+
720+
The example sketch shown below stores incoming characters in a String variable and processes the data when a line-ending character is received:
716721

717722
```arduino
718723
// Variable for storing incoming data
719724
String incoming = "";
720725
726+
// Start UART communication at 9600 baud
727+
void setup() {
728+
Serial.begin(9600);
729+
}
730+
721731
void loop() {
722732
// Check for available data and read individual characters
723733
while (Serial.available()) {
@@ -738,8 +748,16 @@ void loop() {
738748
}
739749
}
740750
}
751+
752+
// Function to process the received data
753+
void processData(String data) {
754+
// Example: Print the received data to the Arduino IDE Serial Monitor
755+
Serial.println("Received: " + data);
756+
}
741757
```
742758

759+
#### Transmit Data
760+
743761
To transmit data to another device via UART, you can use the `Serial.write()` function:
744762

745763
```arduino

0 commit comments

Comments
 (0)