4 Running the Examples

Examples are available for each diagnostic test. Users can generate these examples if the options are enabled in the user interface. For instance, to add the AVR SW_CPU_REGISTER_TEST_01 example:

  1. In the MCC window, navigate to the AVR Diagnostic Library module and enable a diagnostic test (e.g., CPU).
  2. Switch to the CPU tab and enable the Generate Example box of SW_CPU_REGISTER_TEST_01 (see Figure 4-1).
    Figure 4-1. Enabling the SW_CPU_REGISTER_TEST_01 Example
  3. The examples use printf to report the result after running the diagnostic. Select the UART driver under Drivers in the Device Resources panel to print the result over the Universal Asynchronous Receiver and Transmitter (UART).
  4. In the UART(None) tab, select the desired UART Peripheral Library (PLIB) from the drop-down. Note that the tab name will change to the selected UART PLIB.
  5. Redirect Printf to UART. Configure the other options to match the preferred serial terminal settings (see Figure 4-2).
    Figure 4-2. Configuring the UART in AVR128DA48
  6. Click the Generate button.
  7. Include the diag_common_example.h, located in the example folder in the main.c file. This header file contains all the generated example functions.
  8. Call the example function DIAG_CPU_RegistersExample() in main() (see Figure 4-3).
    Figure 4-3. Adding the Diagnostic Example to main.c
  9. Connect a board with the selected device to the PC (e.g., an AVR128DA48 Curiosity Nano).
  10. Build and program the board.
  11. Open and configure a serial terminal to view the example output (see Figure 4-4). Do this by using MPLAB Data Visualizer. To use Data Visualizer, click the
    icon. For more information on how to use Data Visualizer, refer to the MPLAB Data Visualizer user’s guide.
    Figure 4-4. SW_CPU_REGISTER_TEST_01 Output in the Serial Terminal