Skip to content

Commit 2a871d5

Browse files
author
Ethan Layton
committed
MPAE-20216: Readme edits
1 parent 2060512 commit 2a871d5

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

README.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</a>
1010

1111
# Getting Started with SERCOM (UART) Communication on PIC32CM M0+ Devices
12-
This example project demonstrates basic UART communication using the SERCOM peripheral on a PIC32CM JH00 device. The application transmits the message “Hello World” once every 500 ms using the SysTick timer, and the output can be viewed on a serial terminal connected to the board. This project provides a straightforward introduction to initializing SERCOM for UART operation and sending periodic messages.
12+
This example project demonstrates basic UART communication using the SERCOM peripheral on a PIC32CM JH00 device. The application transmits the message “Hello World” once every 500 ms using the SysTick timer, and the output can be viewed on a serial terminal connected to the board. This project provides a straightforward introduction to initializing the SERCOM for UART operation and sending periodic messages.
1313

1414
While this project uses a PIC32CM JH00 device, the same initialization and communication principles apply to other PIC32CM M0+ devices.
1515

@@ -34,8 +34,10 @@ While this project uses a PIC32CM JH00 device, the same initialization and commu
3434
- [MPLAB® XC32 4.60 or newer](https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers/xc32)
3535
- [MPLAB® Code Configurator (MCC) v5.6.2](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator)
3636

37-
## Opening projects in VS Code
38-
This example project was developed in MPLAB X IDE and can also be opened in VS Code using the [MPLAB Extension Pack](https://marketplace.visualstudio.com/items?itemName=Microchip.mplab-extension-pack). Follow the provided instructions [here](https://developerhelp.microchip.com/xwiki/bin/view/software-tools/ides/extensions/get-started/importing-mplab-x-project-vs-code/) to import and run the project in VS Code.
37+
## Opening Projects in Visual Studio Code (VS Code®)
38+
This example project was developed in MPLAB X IDE and can also be opened in VS Code® using the [MPLAB Extension Pack](https://marketplace.visualstudio.com/items?itemName=Microchip.mplab-extension-pack). Follow the provided instructions [here](https://developerhelp.microchip.com/xwiki/bin/view/software-tools/ides/extensions/get-started/importing-mplab-x-project-vs-code/) to import and run the project in VS Code®.
39+
40+
For a step-by-step walkthrough on importing the project, watch the video: [Importing an MPLAB® X Project into Microsoft® VS Code®](https://www.youtube.com/watch?v=cf1bK6aLdlo)
3941

4042

4143
## Related Documentation
@@ -56,26 +58,26 @@ PIC32CM)](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU32/Appli
5658

5759
### UART Communication Concept
5860

59-
UART communication is based on a simple point-to-point connection between two devices. One device’s TX (transmit) pin connects to the other device’s RX (receive) pin, and vice versa. This crossover allows data to flow in both directions, as shown in the diagram below.
61+
UART communication is based on a simple point-to-point connection between two devices. One device’s TX (transmit) pin connects to the other device’s RX (receive) pin, and vice versa. This crossover allows data to flow in both directions, as shown in the following figure.
6062

61-
In this configuration, UART provides a straightforward way to exchange data without the need for a clock signal. For communication to work correctly, both devices must be configured with the same parameters:
63+
In this configuration, the UART provides a straightforward way to exchange data without the need for a clock signal. For communication to work correctly, both devices must be configured with the same parameters:
6264

63-
- Baud Rate – Defines the speed of communication in bits per second. If the baud rates don’t match, the timing of bits will drift and data will be corrupted.
65+
- Baud Rate – Defines the speed of communication in bits per second. If the baud rates do not match, the timing of bits will drift and data will be corrupted.
6466
- Data Bits – Specifies how many bits represent the actual data (commonly 8). Both devices must agree to properly interpret each frame.
6567
- Parity – An optional error-checking bit (None, Even, or Odd). If enabled, both sides must use the same setting to validate data integrity.
6668
- Stop Bits – Mark the end of each data frame (typically 1 or 2). Mismatched stop bits cause framing errors.
6769

68-
Together, these settings ensure that transmitted bits are correctly packaged, sent, and interpreted on the receiving side, ensuring that transmitted bits are correctly interpreted on the receiving side.
70+
Together, these settings ensure that the transmitted bits are correctly packaged, sent, and interpreted on the receiving side.
6971

7072
<br><img src="images/BasicUART.png" alt="BasicUART" width="600">
7173

7274

7375

7476

7577
### Application on PIC32CM:
76-
In this example, the concept is applied using the SERCOM1 peripheral configured as a UART. The onboard debugger uses a Communications Device Class (CDC) interface that appears on the host computer as a virtual COM port, allowing data to stream in both directions between the host and the target device.
78+
In this example, the concept is applied using the SERCOM1 peripheral configured as a UART. The onboard debugger uses a Communications Device Class (CDC) interface that appears on the host computer as a virtual COM port, allowing the data to stream in both directions between the host and the target device.
7779

78-
Characters sent from the host are transmitted on the debugger’s CDC TX pin, while characters received on the CDC RX pin are returned to the host. The UART output can be viewed in a terminal program such as MPLAB Data Visualizer, making it easy to monitor or interact with the application over USB without extra hardware.
80+
Characters sent from the host are transmitted on the debugger’s CDC TX pin, while characters received on the CDC RX pin are returned to the host. The UART output can be viewed in a terminal program such as the MPLAB Data Visualizer, making it easy to monitor or interact with the application over a USB without extra hardware.
7981

8082

8183
<br><img src="images/CDCDebugger.png" alt="CDCDebugger" width="700">
@@ -86,7 +88,7 @@ Characters sent from the host are transmitted on the debugger’s CDC TX pin, wh
8688
The application performs the following sequence:
8789

8890
1. SERCOM1 is initialized as a UART interface with the chosen baud rate.
89-
2. The SysTick timer is initialized provides a 500 ms time base.
91+
2. The SysTick timer is initialized and provides a 500 ms time base.
9092
3. A fixed message string, `Hello World`, is transmitted over the USB CDC connection to the host computer.
9193
4. After 500 ms, the process repeats continuously.
9294

@@ -114,7 +116,7 @@ Once programmed, the device continuously sends the `Hello World` message, which
114116

115117
<br>
116118

117-
7. Click the Make and Program Device button in the MPLAB X IDE toolbar to program the device . Then, verify that the device is successfully programmed.
119+
7. Click the Make and Program Device button in the MPLAB X IDE toolbar to program the device. Then, verify that the device is successfully programmed.
118120
<br><img src="images/Program.png" alt="Program" width="700">
119121
<br><img src="images/programcomplete.png" alt="ProgramComplete" width="700">
120122

@@ -123,7 +125,7 @@ Once programmed, the device continuously sends the `Hello World` message, which
123125
<br>
124126

125127
### View the results:
126-
To view the output of this project, launch MPLAB Data Visualizer from the MPLAB X IDE toolbar. In Data Visualizer, select the serial COM port associated with the PIC32CM JH00 Curiosity Nano and confirm that the settings match the configured SERCOM UART parameters in the Project Configuraiton section.
128+
To view the output of this project, launch the MPLAB Data Visualizer from the MPLAB X IDE toolbar. In the Data Visualizer, select the serial COM port associated with the PIC32CM JH00 Curiosity Nano and confirm that the settings match the configured SERCOM UART parameters in the Project Configuration section.
127129

128130
<br><img src="images/TerminalWindow.gif" alt="TerminalWindow" width="1000">
129131

@@ -140,7 +142,7 @@ The UART pins can be probed with a logic analyzer, where the output should decod
140142

141143
<!-- Provide instructions for configuring the project, including modifying parameters, setting up configuration files, and tuning options when necessary. -->
142144

143-
This example project is already provided as a preconfigured MPLAB X project. Start by opening the project in MPLAB X IDE. Once the project is loaded, launch MPLAB® Code Configurator (MCC) Harmony to review the configuration.
145+
This example project is already provided as a preconfigured MPLAB X project. Start by opening the project in MPLAB X IDE. Once the project is loaded, launch the MPLAB® Code Configurator (MCC) in Harmony to review the configuration.
144146

145147
For detailed instructions on how to create and set up a new MPLAB X project and open MCC Harmony, refer to the this Microchip online reference [here](https://mplab-discover.microchip.com/v2/item/com.microchip.documentation/com.microchip.portal.webhelp/com.microchip.subcategories.tools.development-boards/tool-chain-guide.guid-45e21205-663c-4792-b2c1-e147f4c3ff92.html%23guid-45e21205-663c-4792-b2c1-e147f4c3ff92/1.0.0?view=about&dsl=3+AND+Tool+AND+Chain+AND+Guide)
146148

@@ -171,7 +173,7 @@ To check the system clock, go to Project Graph → Plugins → Clock Configurato
171173

172174
### Step 2: Configuring the System Tick (SysTick)
173175

174-
SysTick is a built-in timer that allows the application to create precise delays without relying on software loops. In this demo, it will be used to add a fixed delay between each `Hello World` message sent over UART.
176+
The SysTick is a built-in timer that allows the application to create precise delays without relying on software loops. In this demonstration, it will be used to add a fixed delay between each Hello World message sent over the UART.
175177

176178
To enable SysTick:
177179

@@ -180,14 +182,14 @@ To enable SysTick:
180182

181183
<br>
182184

183-
2. In the Configuration Options panel, expand Cortex M0+ Configuration and Enable the SysTick option
185+
2. In the Configuration Options panel, expand Cortex M0+ Configuration and enable the SysTick option.
184186
<br><img src="images/SysTickConfig.png" alt="SysTickConfig" width="650">
185187

186188
<br>
187189

188190
### Step 3: Add and Configure the UART Peripheral (SERCOM1)
189191

190-
The device includes multiple SERCOM peripherals that can be configured as UART, SPI, or I²C. On the Curiosity Nano, only SERCOM1 is internally routed to the onboard debugger’s CDC interface, so it must be used for sending UART data to a terminal over USB.
192+
The device includes multiple SERCOM peripherals that can be configured as UART, SPI, or I²C. On the Curiosity Nano, only SERCOM1 is internally routed to the onboard debugger’s CDC interface, so it must be used for sending the UART data to a terminal over a USB.
191193

192194
This information is available in the Pinout section of the [Curiosity Nano User's Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU32/ProductDocuments/UserGuides/PIC32CM-JH-Value-Line-Curiosity-Nano%2B-Touch-Evaluation-+Kit-User%E2%80%99s-Guide-DS70005600.pdf).
193195

@@ -239,16 +241,17 @@ To assign the pins:
239241

240242
<br>
241243

242-
### Step 5: Generate MCC Code
243-
With UART and SysTick configured, the final step is to generate code. MCC creates the initialization files, peripheral drivers, and APIs for UART communication and SysTick timing, preparing the project for application development.
244+
### Step 5: Generate the MCC Code
245+
With the UART and SysTick configured, the final step is to generate the code. The MCC creates the initialization files, peripheral drivers, and APIs for UART communication and SysTick timing, preparing the project for application development.
244246
<br><img src="images/Generate.png" alt="Generate" width="500">
245247

246248
<br>
247249

248250
## Application Source Code
249251
<!-- Describe the main source code structure, including key functions or files, and explain how the application logic works. -->
250252

251-
This code defines a macro for `"Hello World"`, starts the SysTick timer, and enters a loop that sends the `Hello_World` message over UART using `SERCOM1_USART_Write()`. Timing is provided by `SYSTICK_DelayMs()` to create a 500 ms delay and prevent flooding the terminal.
253+
254+
This code defines a macro for `"Hello World"`, starts the SysTick timer, and enters a loop that sends the `"Hello_World"` message over the UART using `SERCOM1_USART_Write()`. Timing is provided by `SYSTICK_DelayMs()` to create a 500 ms delay and prevent flooding the terminal.
252255

253256
<br>
254257

@@ -283,8 +286,13 @@ int main(void)
283286
<br>
284287
285288
## Conclusion
286-
This project showed how to configure SERCOM in UART mode on a PIC32CM M0+ device using MCC Harmony. The system clock, SysTick timer, and SERCOM1 peripheral were set up to send a `"Hello World"` message every 500 ms over the Curiosity Nano’s USB CDC interface. This simple example provides a foundation for expanding into bidirectional communication or more advanced embedded applications.
289+
This project showed how to configure the SERCOM in UART mode on a PIC32CM M0+ device using MCC Harmony. The system clock, SysTick timer, and SERCOM1 peripheral were set up to send a `"Hello World"` message every 500 ms over the Curiosity Nano’s USB CDC interface. This simple example provides a foundation for expanding into bidirectional communication or more advanced embedded applications.
287290
288291
289292
## Related Projects
290-
<!-- Add links, descriptions or any details of related projects of this example, if any -->
293+
294+
- [Getting Started with Blink LED on PIC32CM M0+ Devices](https://github.com/microchip-pic-avr-examples/pic32cmjh-blink-led-mplab-harmony)
295+
- [Getting Started with Analog-to-Digital Converters (ADC) on PIC32CM M0+ Devices](https://github.com/microchip-pic-avr-examples/pic32cmjh-basic-adc-mplab-harmony)
296+
- [Getting Started with QTouch® Button and Peripheral Touch Controller on PIC32CM M0+ Devices](https://github.com/microchip-pic-avr-examples/pic32cmjh-basic-ptc-mplab-harmony)
297+
- [Getting Started with SERCOM (I²C) Communication on PIC32CM M0+ Devices](https://github.com/microchip-pic-avr-examples/pic32cmjh-basic-i2c-mplab-harmony)
298+
- [Getting Started with SERCOM (SPI) Communication on PIC32CM M0+ Devices](https://github.com/microchip-pic-avr-examples/pic32cmjh-basic-spi-mplab-harmony)

0 commit comments

Comments
 (0)