MPLAB® Harmony v3 Drivers and System Services on SAM E70/S70/V70/V71: Step 2

Last modified by Microchip on 2024/09/27 09:47

Configure the Timer System Service.

Under the bottom left Device Resources tab, expand Harmony > System Services.

Double-click or drag and drop Time to add the Timer System Service to the project graph.

Timer System Service

Figure 1

A popup window will appear. Select the options as shown in Figure 2 and 3.

Core Component Activation Popup

Figure 2

FreeRTOS Component Auto-Activation Popup

Figure 3

MPLAB® Harmony v3 on MPLAB Code Configurator (MCC) by default adds the FreeRTOS™ block when a project with MPLAB Harmony Core (Drivers and System Services) is developed. Since this application is not intended to be developed using FreeRTOS, the FreeRTOS block is not activated as shown in Figure 3.

TimerSYS Core added

Figure 4

Associate the Timer System service to Timer Instance 0 (TC0) by right-clicking on the red diamond as shown in Figure 5.

Timer System Service

Figure 5

TimerSYS TC Connected

Figure 6

Select TC0 Peripheral Library and notice the default configuration by expanding Channel 0.

TC default

Figure 7

Back to Top


Configure the Inter-Integrated Circuit (I²C) Driver and I²C pins.

Under the Device Resources tab, expand Harmony > Drivers.

  • Select and double-click on I²C to add the I²C driver to the project.
Select and double-click on I²C to add the I²C driver to the project

Figure 8

  • Associate I²C driver with I²C instance 0 (TWIHS0) peripheral by right clicking on the red diamond.
I2C driver instance

Figure 9

I2C driver project graph PLIB linked

Figure 10

  • Click on Instance 0 under I2C Driver to view the Configuration Options. Change the Number of Clients to 2.
I2C driver client changes

Figure 11

  • The above configuration allows the same instance of driver to be used by two different clients. The first application client interfaces with the Temperature Sensor and the second application client interfaces with the Electrically Erasable Programmable Read-Only Memory (EEPROM).
  • The number of clients for each driver instance is automatically set to one. MCC assumes a minimum of one client for each instance of the driver.
I2C driver multiclient

Figure 12

If the application had two or more devices that were interfaced through different I²C peripherals, then the driver had to be configured to enable multiple instance support. Multiple instance support is enabled by clicking on the + sign on the I²C driver block. Every click on the + sign adds a new instance to the driver. Each instance can be configured separately. 

  • Select TWIHS0 Peripheral Library and notice the default configuration by expanding the hardware settings.
TWIHS0 Peripheral Library

Figure 13

The TWIHS0 (I²C) retains the default 400 kHz speed because the temperature sensor chip and EEPROM on I/O1 Xplained Pro Extension Kit can operate at 400 kHz I²C speed.

Open the Pin Configuration tabs by clicking Project Graph > Plugins > Pin Configuration.

Open pin configuration

Figure 14

Select the Pin Settings tab and sort the entries by Ports, as shown in Figure 15.

TWIHS pins setup

Figure 15

Now, select the Pin Settings tab and then scroll down to the TWIHS0 module as follows:

  • Enable I²C Clock (TWIHS0_TWCK0) on PA4 (Pin #77)
  • Enable I²C Data (TWIHS0_TWD0) on PA3 (Pin #91)
TWIHS pins setup

Figure 16

This completes the configuration of the I²C driver. The application code will use the I²C driver Application Programming Interfaces (APIs) to read the temperature from the temperature sensor and store it in EEPROM. The application also retrieves last five temperature values stored in the EEPROM.

Back to Top


Configure the Universal Synchronous Asynchronous Receiver Transmitter (USART) Driver and USART pins.

Under the Device Resources tab, expand Harmony > Drivers.

  • Double-click on USART to add the USART driver to the project.
USART driver select

Figure 16

  • Associate USART Driver with USART instance 1 (USART1) peripheral by right clicking on the red diamond.
USART driver instance

Figure 17

USART driver project graph PLIB linked

Figure 18

  • Click on Instance 0 under USART Driver to view the Configuration Options. Select the Use DMA for Transmit check box.
I2C driver instance changes

Figure 19

  • The USART driver is configured to operate in Direct Memory Access (DMA) mode (DMA is used to transfer data from memory to the USART TX register).
  • The DMA Channel for Transmit is selected by default by the driver as channel 0. The user does not have to do any further DMA configurations. The driver internally takes care of all the DMA-specific configurations.
  • The USART RX (receive) operations happen in non-DMA mode (Regular Interrupt mode).
  • Select the USART1 Peripheral Library and notice the default configuration by expanding USART1 in Configuration Options.
USART PLIB configuration

Figure 20

Select the Pin Settings tab and then scroll down to the Pin ID PA21 and PB4​​​ as shown in Figure 21.

  • Enable USART1_TXD1 on PB4 (Pin #105)
  • Enable USART1_RXD1 on PA21 (Pin #32)
USART pins setup

Figure 21

The application will use the USART driver for printing messages on the serial terminal and receiving input from the user to retrieve the last five stored values from the EEPROM.

Back to Top