Step 2.1: Configure Real-Time Clock (RTC) Peripheral Library
In the Clock Easy View, open the Peripheral Clock Configuration window by clicking on the Peripheral Clock Configuration button.
Once the window is opened, scroll down to the RTC peripheral and select GCLK1 (1 kHz) as the source clock to generate the peripheral clock frequency.
When a peripheral is added to the project, the peripheral clock is automatically fed by the GCLK0. However, you must configure the peripheral clocks according to your needs (power consumption, performance, etc.)
Go back to the project graph and configure the RTC PLIB to generate a compare interrupt every 500 milliseconds.
The Compare Value is set as 0x200. This compare value generates an RTC compare interrupt every 500 milliseconds
- RTC clock = 1024 Hz
- RTC Prescaler = 1
- Required Interrupt rate = 500 ms
Hence, Compare Value = (500/1000) x 1024 = 512 (i.e., 0x200).
Step 2.2: Configure I²C Peripheral Library, I²C Pins, and Verify I²C Clock
Under the Available Components tab, expand Peripherals > SERCOM.
Double click on SERCOM2 to add the SERCOM instance 2 to the project.
Select the SERCOM 2 Peripheral Library and configure it for the I²C protocol.
- 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.
- 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).
- SERCOM2 (as I²C) retains the default 100 nanoseconds for I²C Trise time because it aligns with the maximum (300 nanoseconds) input rise time in the specification of the temperature sensor chip (AT30TSE758).
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.3: Configure Universal Synchronous Asynchronous Receiver Transmitter (USART) Peripheral Library, USART Pins, and Verify USART Clock
In Clock Easy View, open the Peripheral Clock Configuration by clicking on the Peripheral Clock Configuration button.
Once the window is opened, scroll down to the SERCOM3_CORE peripheral and set GCLK2 (32 kHz) as the source clock to generate the peripheral clock frequency.
Note: The default main clock source will take time to settle once after wakeup from Standby Sleep mode. So, the USART clock source is changed to GLCK2, as GCLK2 sourcing from XOSC32K oscillator and this XOSC32K will run even in Standby Sleep mode.
Table of Contents