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:
- In the MCC window, navigate to the AVR Diagnostic Library module and enable a diagnostic test (e.g., CPU).
- Switch to the CPU tab and enable the Generate Example box of SW_CPU_REGISTER_TEST_01 (see Figure 4-1).
- 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). - 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.
- Redirect Printf to UART. Configure the other options to match the preferred serial terminal settings (see Figure 4-2).
- Click the Generate button.
- Include the
diag_common_example.h
, located in the example folder in themain.c
file. This header file contains all the generated example functions. - Call the example function
DIAG_CPU_RegistersExample()
inmain()
(see Figure 4-3). - Connect a board with the selected device to the PC (e.g., an AVR128DA48 Curiosity Nano).
- Build and program the board.
- 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.