Migrating ASF SAM C21 Application to MPLAB Harmony v3 PIC32CM MC: Step 2

Step 2.1: Configure I²C Peripheral Library and I²C Pins

1

Under the Available Components tab, expand Peripherals > SERCOM.

Double click on SERCOM2 to add the SERCOM instance 2 to the project.

sercom_selection.png

Select the SERCOM 2 Peripheral Library and configure it for the I²C protocol.

sercom_setup.png
  • The SERCOM2 (as I²C) retains the default 100 kHz speed because the temperature sensor chip on the I/O1 Xplained Pro Extension Kit can operate at 100 kHz I²C speed.
  • The SERCOM2 (as I²C) retains the default 50-100 nanoseconds hold time for Serial Data (SDA) Hold Time because it aligns with the minimum (50 nanoseconds) start hold time in the specification of the temperature sensor chip (AT30TSE758).
  • The SERCOM2 (as I²C) retains the default 100 nanoseconds for I2C Trise time because it aligns with the maximum (300 nanoseconds) input rise time in the specification of the temperature sensor chip (AT30TSE758).

2

Open the Pin Configuration tab by clicking MHC > Tools > Pin Configuration.

open_pin_configuration.png

3

Select the MHC Pin Settings tab and sort the entries by Ports.

sercom_pins_setup_1.png

Now, select the MHC Pin Table tab and then scroll down to the SERCOM2 module as follows.

  • Enable I²C Clock (I2C_SCK)(SERCOM2_PAD1) on Pin #22 (PA13)
  • Enable I²C Data (I2C_SDA)(SERCOM2_PAD0) on Pin #21 (PA12)
sercom_pins_setup_2.png

When a peripheral is added to the project, the peripheral clock is automatically fed by the GCLK0.

This completes the configuration of the I²C peripheral library. The application code will use the I²C PLIB Application Programming Interfaces (APIs) to read the temperature from the temperature sensor.

Step 2.2: Configure Universal Synchronous Asynchronous Receiver Transmitter (USART) Peripheral Library, USART Pins, and link STDIO Library

1

Under the tab Available Components tab, expand Peripherals > SERCOM.

Double click on SERCOM0 to add the SERCOM instance 0 to the project.

sercom_selection_for_uart.png

Associate STDIO tool with SERCOM instance 0 (USART) peripheral by right clicking on the yellow diamond.

stdio_selection.png
stdio_linked.png

Select the SERCOM0 Peripheral Library in the Project Graph, verify default SERCOM Operation Mode configuration is set as USART and configure it.

uart_sercom_setup.png

2

Select the Pin Table tab and then scroll down to the SERCOM0 module as follows.

  • Enable USART_TX (SERCOM0_PAD2) on Pin #11 (PA06)
  • Enable USART_RX (SERCOM0_PAD3) on Pin #12 (PA07)
uart_sercom_pins_setup.png



Next Step >

© 2022 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.