Harmony v3 Drivers and Middleware on PIC32MZ EF MCUs Using FreeRTOS: Step 2
Last modified by Microchip on 2023/11/09 09:07
Configure I²C Driver and I²C pins
Under the Available Components tab, 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 the I²C driver with I²C instance 1 (I²C1) peripheral by right clicking on the red diamond highlighted in the accompanying image.
- Click on Instance 0 under I²C Driver to view the Configuration Options. Change the Number of clients to 2.
- Click on I2C to verify the driver is configured in Synchronous mode.
- Select I2C1 Peripheral Library and notice the default configuration by expanding Hardware Settings.
In MHC, open the pin configuration tabs by clicking Tools > Pin Configuration.
Select the MHC Pin Settings tab and sort the entries by Ports as shown in the accompanying image.
- Now, select the MHC Pin Table tab and then scroll down to the I2C 1 module as shown in the accompanying image.
- Enable I²C Clock (SCL1) on RA14 (Pin #95).
- Enable I²C Data (SDA1) on RA15 (Pin #96).
Configure Universal Synchronous Asynchronous Receiver Transmitter (USART) Driver and USART pins
Under the Available Components tab, expand Harmony > Drivers.
Double click on USART to add the USART Driver to the project.
- Associate the USART Driver with UART instance 6 (UART6) peripheral by right clicking on the red diamond highlighted in the accompanying image.
- Verify that the USART Driver is configured to run in Synchronous mode by clicking on the USART block as shown in the accompanying image.
- Click on Instance 0 under USART Driver to view the Configuration Options. Change the Number of Clients of the USART Driver Instance from 0 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 UART6 Peripheral Library in the Project Graph and configure it for UART protocol, including setting the Baud Rate to 115,200 Hz.
Select the Pin Table tab and then scroll down to the UART6 module as shown in the accompanying image.
- Enable USART_TX (U6TX) on RF2 (Pin #79).
- Enable USART_RX (U6RX) on RF13 (Pin #57).