Digit Recognition AI/ML Application on SAM E51 IGAT Curiosity Evaluation Kit Using MPLAB® Harmony v3: Step 2
Configure USART Peripheral Library, Pins and Clock
The USART will be used to print the application debug log and application output.
Under the left tab Resource Management (MCC), go to Device Resources and expand Libraries > Harmony > Peripherals > SERCOM.
Click on the green plus symbol beside SERCOM 2 to add the SERCOM instance 2 (SERCOM 2 PLIB) to the project.
Associate the STDIO tool to SERCOM instance 2 (USART) peripheral by right-clicking on the yellow diamond.
In the Clock Easy View window, open the peripheral clock configuration by clicking on the Peripheral Clock Configuration button.
Once the window is opened, scroll down to the SERCOM2_CORE peripheral and set GCLK2 (48 MHz) as the source clock to the SERCOM2 peripheral.
Select the SERCOM 2 Peripheral Library in the Project Graph and configure SERCOM2 on Configuration Options. As this USART will be used to print the debug information and application output, the default baud rate of 115,200 Hz is enough. Verify the default baud rate is set to 115,200 Hz.
From the Project Graph tab, select Plugins > Pin Configuration to launch the Pin Configuration windows. Three new windows, Pin Diagram, Pin Table, and Pin Settings are opened in the project’s main window.
Select the Pin Settings tab of MCC and then scroll down to the pin numbers 29 and 30 and configure the two pins as shown:
- Configure Pin #29 as SERCOM2_PAD0 (USART_TX) i.e. PA12
- Configure Pin #30 as SERCOM2_PAD1 (USART_RX) i.e. PA13
The USART pins are configured as per the SAM E51 Integrated Graphics and Touch Curiosity Evaluation kit virtual COM Port design.
Configure Timer System Service and verify its Clock
The timer system service uses the TC0 Timer Peripheral Library (PLIB) and is needed to fulfill the shared timer by different tasks in the application.
Under the left tab Resource Management (MCC), go to Device Resources and expand Libraries > Harmony > Peripherals > TC. Click on the green plus symbol beside TC0 to add the Timer Counter instance 0 (TC0 PLIB) to the project.
Associate Timer System Service tool to TC0 peripheral by right-clicking on the yellow diamond.
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 TC0, TC1 peripheral and verify GCLK1 (32 kHz) as the source clock to TC0 peripheral.
Select and verify the default TC0 and Timer System Service configurations.
Configure TC3 Timer Peripheral Library (PLIB) and Clock
The timer TC3 is used to control the display backlight using the Timer compare PWM output.
Under the left tab Resource Management (MCC), go to Device Resources and expand Libraries > Harmony > Peripherals > TC.
Click on the green plus symbol beside TC3 to add the Timer Counter instance 3 (TC3 PLIB) to the project.
In Clock Easy View, configure the GCLK Generator 4 block as shown to generate a 1 MHz clock.
Open the peripheral clock configuration by clicking on the Peripheral Clock Configuration button.
Once the window is opened, scroll down to the TC2, TC3 peripheral and set GCLK4 (1 MHz) as the source clock to TC3 peripheral.
Select the TC3 in the Project Graph and configure TC3 on Configuration Options.
The Timer TC3 is configured for 100 usecs compare period. Users can able to change the timer compare period in multiples of 100 usecs in run time using TC3 timer APIs.
Configure RTC Peripheral Library
The Touch Library uses the RTC timer as a counter, and the default RTC configuration is sufficient for Touch Library.
Under the left side tab Resource Management (MCC), go to Device Resources and expand Libraries > Harmony > Peripherals > RTC.
Click on the green plus symbol beside RTC to add the RTC PLIB to the project graph.
From the Clock Easy View MCC plugin, verify that the RTC clock is set to run at a 1 kHz internal ultra-low-power clock.
When a module is added to the project graph, MCC automatically enables the clock to the module. The default RTC clock source is a 1 kHz internal ultra-low-power clock (OSCULP1K).
Select and verify the default RTC peripheral configuration.