Skip to content

microchip-pic-avr-examples/avr128da48-tuning-internal-hf-osc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCHP

Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature

The repository provides an MPLAB® X IDE project, highlighting the Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature present on the AVR® DA family of microcontrollers as described in TB3234 - Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature.

Related Documentation

More details and code examples on the AVR128DA48 can be found at the following links:

Software Used

Hardware Used

Use Cases

  1. Configure the OSCHF to run at 1 MHz and activate or deactivate the auto-tune feature.

    • Use case description: The purpose of this use case is to configure the OSCHF to run at 1 MHz, drive the main clock, and enable frequency output on the CLKOUT pin. Two frequency measurements on the CLKOUT pin will be made using an oscilloscope with auto-tune feature activated and deactivated.
    • Result: A comparison between the two scenarios (auto-tune feature activated and auto-tune feature deactivated) will be made.
  2. Configure the OSCHF to run at 4 MHz and activate or deactivate the auto-tune feature.

    • Use case description: The purpose of this use case is to configure the OSCHF to run at 4 MHz, drive the main clock, and enable frequency output on the CLKOUT pin. Two frequency measurements on the CLKOUT pin will be made using an oscilloscope with auto-tune feature activated and deactivated.
    • Result: A comparison between the two scenarios (auto-tune feature activated and auto-tune feature deactivated) will be made.
  3. Configure the OSCHF to run at 24 MHz and activate or deactivate the auto-tune feature.

    • Use case description: The purpose of this use case is to configure the OSCHF to run at 24 MHz, drive the main clock, and enable frequency output on the CLKOUT pin. Two frequency measurements on the CLKOUT pin will be made using an oscilloscope with auto-tune feature activated and deactivated.
    • Result: A comparison between the two scenarios (auto-tune feature activated and auto-tune feature deactivated) will be made.
  4. Configure the OSCHF to run at 4 MHz with incorrect tuning value.

    • Use case description: The purpose of this use case is to configure the OSCHF to run at 4 MHz, drive the main clock, and enable frequency output on the CLKOUT pin. An error injection will be made to the tune register to check if the auto-tune mechanism will be able to correct it. Two frequency measurements on the CLKOUT pin will be made using an oscilloscope with the incorrect frequency tune input and with auto-tune feature activated.
    • Result: A comparison between the two scenarios (auto-tune feature activated and incorrect tune setting) will be made.

Operation

To program the Curiosity Nano board with this MPLAB X project, follow the steps provided in the How to Program the Curiosity Nano Board chapter.

Setup

The following peripheral and clock configurations are set up using the bare metal code inside the main.c source file for the AVR128DA48.

Setup for Use Case #1 - Configure the OSCHF to Run at 1 MHz and Activate or Deactivate the Auto-Tune Feature

The following configurations must be made for this project:

Clock:

  • OSCHF as main clock source
  • OSCHF frequency set to 1 MHz (CLKCTRL_FRQSEL_1M_gc)
  • Enable external 32 kHz crystal oscillator
  • Enable CLKOUT on PA7 pin
Pin Configuration
PC7 (SW0) Digital input


Pressing the SW0 button on the AVR128DA48 Curiosity Nano will enable the auto-tune feature, then it will disable it.

Results
The following figure presents the output signal on PA7 pin (CLKOUT) with auto-tune feature deactivated (CLK configured to run at 1 MHz).


The following figure presents the output signal on PA7 pin (CLKOUT) with auto-tune feature activated (CLK configured to run at 1 MHz).

Setup for Use Case #2 - Configure the OSCHF to Run at 4 MHz and Activate or Deactivate the Auto-Tune Feature

The following configurations must be made for this project:

Clock:

  • OSCHF as main clock source
  • OSCHF frequency set to 4 MHz (CLKCTRL_FRQSEL_4M_gc)
  • Enable external 32 kHz crystal oscillator
  • Enable CLKOUT on PA7 pin
Pin Configuration
PC7 (SW0) Digital input

Change the frequency settings to 4 MHz as described in TB3234 - Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature and program the project to the board (see instructions above).

Results
The following figure presents the output signal on PA7 pin (CLKOUT) with auto-tune feature deactivated (CLK configured to run at 4 MHz).


The following figure presents the output signal on PA7 pin (CLKOUT) with auto-tune feature activated (CLK configured to run at 4 MHz).

Setup for Use Case #3 - Configure the OSCHF to Run at 24 MHz and Activate or Deactivate the Auto-Tune Feature

The following configurations must be made for this project:

Clock:

  • OSCHF as main clock source
  • OSCHF frequency set to 24 MHz (CLKCTRL_FRQSEL_24M_gc)
  • Enable external 32 kHz crystal oscillator
  • Enable CLKOUT on PA7 pin
Pin Configuration
PC7 (SW0) Digital input

Change the frequency settings to 24 MHz as described in TB3234 - Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature and program the project to the board (see instructions above).

Results
The following figure presents the output signal on PA7 pin (CLKOUT) with auto-tune feature deactivated (CLK configured to run at 24 MHz).


The following figure presents the output signal on PA7 pin (CLKOUT) with auto-tune feature activated (CLK configured to run at 24 MHz).

Setup for Use Case #4 - Configure the OSCHF to Run at 4 MHz With Incorrect Tuning Value

The following configurations must be made for this project:

Clock:

  • OSCHF as main clock source
  • OSCHF frequency set to 4 MHz (CLKCTRL_FRQSEL_4M_gc)
  • Enable external 32 kHz crystal oscillator
  • Enable CLKOUT on PA7 pin
Pin Configuration
PC7 (SW0) Digital input

Change the frequency settings to 4 MHz with incorrect tune value as described in TB3234 - Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature and program the project to the board (see instructions above).

Results
The following figure presents the output signal on PA7 pin (CLKOUT) with incorrect tuning value (CLK configured to run at 4 MHz).


The following figure presents the output signal on PA7 pin (CLKOUT) with auto-tune feature activated (CLK configured to run at 4 MHz).

Summary

The TB3234 - Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature document provides four use cases for auto-tune implementation.

How to Program the Curiosity Nano Board

This chapter demonstrates how to use the MPLAB X IDE to program an AVR device with an Example_Project.X. This is applicable to other projects.

  1. Connect the board to the PC.

  2. Open the Example_Project.X project in MPLAB X IDE.

  3. Set the Example_Project.X project as main project.
    Right click the project in the Projects tab and click Set as Main Project.

  4. Clean and build the Example_Project.X project.
    Right click the Example_Project.X project and select Clean and Build.

  5. Select AVRxxxxx Curiosity Nano in the Connected Hardware Tool section of the project settings:
    Right click the project and click Properties.
    Click the arrow under the Connected Hardware Tool.
    Select AVRxxxxx Curiosity Nano (click the SN), click Apply and then click OK:

  6. Program the project to the board.
    Right click the project and click Make and Program Device.



Menu

About

Internal High-Frequency Oscillator Calibration Using the Auto-Tune Feature

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 8