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

Step 2.1: Configure Timer System Service

1

Under the bottom left Available Components 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_adding.png

2

A popup window will appear, select the option as shown below.

core_popup_window.png
freertos_popup_window.png

Harmony v3 MPLAB® Harmony Configurator (MHC) by default adds the FreeRTOS block when a project with 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 the above figure.

timersys_core_added.png

3

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

associate_timersys_with_tc.png
timersys_tc_connected.png

4

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

tc_default.png

Step 2.2: Configure I²C Driver and I²C pins

1

Under the Available Components tab, expand Harmony > Drivers.

  • Select and double click on I²C to add the I²C driver to the project.
i2c_driver_select.png
i2c_driver_project_graph.png
  • Associate I²C driver with I²C instance 0 (TWIHS0) peripheral by right clicking on the red diamond.
i2c_driver_instance.png
i2c_driver_project_graph_plib_linked.png
  • Click on Instance 0 under I2C Driver to view the Configuration Options. Change the Number of Clients to 2.
i2c_driver_client_changes.png
  • 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 EEPROM.
  • The Number of Clients for each driver instance is automatically set to one. MHC assumes a minimum of one client for each instance of the driver.
i2c_driver_multiclient.png

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 Hardware Settings.
twihs_plib_conf.png

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.

2

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

open_pin_configuration.png

3

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

twihs_pins_setup_1.png

Now, select the MHC Pin Table tab and then scroll down to the TWIHS0 module as shown below.

  • Enable I²C Clock (TWIHS0_TWCK0) on PA04 (Pin #77)
  • Enable I²C Data (TWIHS0_TWD0) on PA03 (Pin #91)
twihs_pins_setup_2.png

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.

Step 2.3: Configure Universal Synchronous Asynchronous Receiver Transmitter (USART) Driver and USART pins

1

Under the Available Components tab, expand Harmony > Drivers.

  • Double click on USART to add the USART driver to the project.
usart_driver_select.png
usart_driver_project_graph.png
  • Associate USART Driver with USART instance 1 (USART1) peripheral by right clicking on the red diamond.
usart_driver_instance.png
usart_driver_project_graph_plib_linked.png
  • Click on Instance 0 under USART Driver to view the Configuration Options. Select the Use DMA for Transmit check box.
i2c_driver_instance_changes.png
  • 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 happens in non-DMA mode (Regular Interrupt mode).
  • Select the USART1 Peripheral Library in the Project Graph and configure it for USART protocol, including setting the baud rate to 115200 Hz.
usart_plib_conf.png

2

Select the Pin Table tab and then scroll down to the USART1 module as shown below.

Enable USART_TX on PB04 (Pin #105).
Enable USART_RX on PA21 (Pin #32).

usart_pins_setup.png

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.



Next Step >

© 2024 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.