MPLAB® Harmony v3 Drivers on SAM C21 MCUs Using FreeRTOS™: Step 2
Configure I²C Driver and I²C Pins
Click on the Resource Management [MCC] tab, In the Device Resources , expand Harmony > Drivers.
- Select and double click on I2C to add the I²C driver to the project.
Select FreeRTOS and view the Configuration Options on the right. Depending on the requirements of the application, the FreeRTOS™ default configuration can be changed using the GUI. For this tutorial, you will use the default configuration.
- Associate I²C driver with I²C instance 0 (SERCOM2) peripheral by right clicking on the red diamond.
- Click on Instance 0 under I²C Driver to view the Configuration Options. Change the Number of Clients to 2.
- Click on I²C to verify the driver is configured in Synchronous mode.
- Select SERCOM2 Peripheral Library and notice the default configuration by expanding Hardware Settings.
In MCC, open the pin configuration tabs by clicking Project Graph > Plugins > Pin Configuration.
Select the MCC Pin Settings tab and sort the entries by Ports.
Now, select the MCC Pin Table tab and then scroll down to the SERCOM2 module.
- Enable I²C Data (SDA)(SERCOM2_PAD0) on PA12 (Pin #29)
- Enable I²C Clock (SCL)(SERCOM2_PAD1) on PA13 (Pin #30)
Configure Universal Synchronous Asynchronous Receiver Transmitter (USART) Driver and USART Pins
Click on the Resource Management [MCC] tab, In the Device Resources, expand Harmony > Drivers.
- Double-click on USART to add the Universal Synchronous Asynchronous Receiver Transmitter (USART) driver to the project.
- Associate USART Driver with USART instance (SERCOM4) peripheral by right-clicking on the red diamond.
- Verify USART driver is configured to run in Synchronous mode by clicking on the USART block.
- Click on Instance 0 under USART Driver to view the Configuration Options. Change the USART driver Instance 0 number of clients to 3. The User Input Thread will use the USART driver to read the character input on the serial terminal. The Sensor and EEPROM threads will use the USART driver to print temperature values on the serial terminal.
- Select the SERCOM4 Peripheral Library in the Project Graph and configure it for USART protocol, including setting the baud rate to 115200 Hz.
Select the Pin Table tab and then scroll down to the SERCOM4 module.
- Enable USART_TX on PB10 (Pin #23)
- Enable USART_RX on PB11 (pin #24)