Skip to content

Commit b2ff81f

Browse files
committed
Content update (UART section information)
1 parent 39d5a14 commit b2ff81f

File tree

1 file changed

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

1 file changed

+41
-30
lines changed

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

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -702,30 +702,38 @@ The Portenta C33 supports UART communication. The pins used in the Portenta C33
702702
| `92` | `P603` |
703703
| `93` | `P604` |
704704

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

707-
#### UART Initialization
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.
708708

709-
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 UART, read incoming data, and transmit data with the Portenta C33 board, which are common tasks for serial communication.
710710

711711
```arduino
712-
// Start UART communication at 9600 baud
713-
Serial.begin(9600);
714-
```
715-
716-
#### Receive Data
712+
/**
713+
UART Communication
714+
Name: UARTCommunication.ino
715+
Purpose: This sketch demonstrates UART communication on the Portenta C33
717716
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.
717+
@author Arduino Product Experience Team
718+
@version 1.0 03/06/24
719+
*/
719720
720-
The example sketch shown below stores incoming characters in a String variable and processes the data when a line-ending character is received:
721+
// Include the necessary libraries for UART communication
722+
#include <Arduino.h>
721723
722-
```arduino
723724
// Variable for storing incoming data
724725
String incoming = "";
725726
726-
// Start UART communication at 9600 baud
727727
void setup() {
728+
// Begin serial communication at a baud rate of 9600
728729
Serial.begin(9600);
730+
731+
// Wait for the serial port to connect
732+
// This is necessary for boards that have native USB
733+
while (!Serial) {}
734+
735+
// Print a message to the Serial Monitor to indicate setup is complete
736+
Serial.println("UART Communication Setup Complete");
729737
}
730738
731739
void loop() {
@@ -747,33 +755,36 @@ void loop() {
747755
incoming += c;
748756
}
749757
}
758+
759+
// Example of transmitting data
760+
// Transmit the string "Hello world!" every second
761+
// Wait for 1 second before sending again
762+
Serial.println("Hello world!");
763+
delay(1000);
750764
}
751765
752-
// Function to process the received data
766+
/**
767+
Processes the received data
768+
This function can be modified to perform different actions based on the received data
769+
770+
@param data The received data as a String
771+
@return none
772+
*/
753773
void processData(String data) {
754-
// Example: Print the received data to the Arduino IDE Serial Monitor
755-
Serial.println("Received: " + data);
774+
// Print the received data to the Arduino IDE Serial Monitor
775+
Serial.println("- Received: " + data);
756776
}
757777
```
758778

759-
#### Transmit Data
760-
761-
To transmit data to another device via UART, you can use the `Serial.write()` function:
779+
Let's analyze the example sketch. First, the necessary configurations are made:
762780

763-
```arduino
764-
// Transmit the string "Hello world!
765-
Serial.write("Hello world!");
766-
```
781+
- The UART communication is initialized at a baud rate of 9600.
782+
- A loop continuously checks for available data and reads individual characters, storing them in a `String` variable.
783+
- A newline character indicates the end of a message, triggering the processing function.
767784

768-
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:
785+
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.
769786

770-
```arduino
771-
// Transmit the string "Hello world!"
772-
Serial.print("Hello world!");
773-
774-
// Transmit the string "Hello world!" followed by a newline character
775-
Serial.println("Hello world!");
776-
```
787+
You should see the following output in the Arduino IDE's Serial Monitor:
777788

778789
### Wi-Fi®
779790

0 commit comments

Comments
 (0)