4. Running The Demonstration Example¶
This section describes the steps required to prepare the Pro DevKit and other tools to successfully run the example code. A serial terminal, an MPC4822 DAC module, a digital multimeter, and optionally a logic analyzer are required for testing and verifying the code. In addition, a breadboard and a few jumper wires are required to connect the SPI module to the Pro DevKit. If you are not familiar with the recommended process on how to clone a project or configure a serial terminal, read the Starting a Project tutorial.
There are two main methods to verify the correct behavior of the demonstrated code. The first method is to use a Serial Terminal and the second is to use a logic analyzer. Both cases are given below as a logic analyzer can be quite an expensive tool.
4.1. Verifying with a Serial Terminal¶
- Establish a connection between the target device and your PC through the USB2(DBG) port of the motherboard. This port is used both for powering and communicating to the DA1468x SoC. For this tutorial a Pro DevKit is used.
- Import and then make a copy of the freertos_retarget sample code found in the SDK of the DA1468x family of devices.
Note
It is essential to import the folder named scripts
to perform various operations (including building, debugging, and downloading).
- In the newly created project, create a new
platform_devices.h
header file under the project’s/config
folder. To do this:- Right-click on the
/sdk/adapters/include/platform_devices.h
header file (1) and select Copy (2).
- Right-click on the
- Right-click on the
/config
folder (3) and select Paste (4).
Note
If a new platform_devices.h
file is not created in /config
directory,
the application will inherit the default macro definitions from /sdk/adapters/include/platform_devices.h
.
- In the target application, add/modify all the required code blocks as illustrated in the Code Overview section.
Note
It is possible for the defined macros not to be taken into consideration instantly. Hence, resulting in errors during compile time. If this is the case, the easiest way to deal with the issue is to: right-click on the application folder, select Index > Rebuild and then Index > Freshen All Files.
- Build the project either in Debug_QSPI or Release_QSPI mode and burn the generated image to the chip.
- Connect the DAC module to the Pro DevKit. Fig. 16 illustrates the pin connections required to configure the MCP4822 module. For more information on the DAC module used, read the manufacturer datasheet.
Note
A shortcut between MOSI (P3_2) and MISO (P3_1) pins on the Pro DevKit must be done for testing the chip in duplex mode.
- Connect a digital multimeter to VoutB pin of the DAC module.
- Press the K2 button on Pro DevKit. This step starts the chip executing its firmware.
- Open a serial terminal (115200, 8-N-1) and press the K1 button on Pro DevKit. A debugging message is displayed on the console indicating whether or not the duplex SPI transaction has been successfully executed.
- Verify that the analog output value of the DAC module increments until it reaches a value close to 2.5 V. The read value is then wrapped around starting from 0 V. Note that the internal Vref signal of the module is set to 2.5 V.
4.2. Verifying with a Logic Analyzer¶
This step is optional and is intended for those who are interested in using an external logic analyzer to capture the SPI signals during a transaction
- With the whole system up and running, open the software that controls the logic analyzer. For this step a logic analyzer from Saleae Incorporation and its official software was used.
- Connect the logic analyzer to the Pro DevKit. To do this, you should:
- Connect a channel from the logic analyzer to P3_0 pin of Pro DevKit. This is the
Clock
signal (SCK). - Connect a channel from the logic analyzer to P3_2 pin of Pro DevKit. This is the
Master Output Slave Input
signal (MOSI). - Connect a channel from the logic analyzer to P3_4 pin of Pro DevKit. This is the
Chip Selec
signal (CS).
- Connect a channel from the logic analyzer to P3_0 pin of Pro DevKit. This is the
- Press the K1 button on Pro DevKit and capture the SPI duplex transaction (loopback test).
- At any time, capture an SPI write transaction between the system and the MCP4822.