Step 5: Build, Program and Observe the Output
Hardware Setup
Connect the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit to the host PC using a Type-A male to Micro-B USB cable. Plug the cable into the Micro-B USB (debug USB) port on the evaluation kit.

Open the Project Properties, under Connected Hardware Tool section, and then select the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit as shown in the accompanying image.

Then click Apply and Ok.
Building the Project
To build the project, select the Clean and Build Main Project option from the Clean and Build drop-down menu.

Observe that the project has compiled and loaded successfully, as indicated by the BUILD SUCCESSFUL message in the Output window.

Debugging and Observing the Output
Set a breakpoint as shown in the accompanying image.

Right click on the sram_global variable and click on New Watch... (or use shortcut Ctrl + Shift + F9).

Click Ok in the New Watch window.

Click the Debug Main Project button to debug the project on the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit.

Once the debugging is complete, you can notice the Output window as shown in the accompanying image.

Go to the Variables window and observe that the address and value of the SRAM variable are displayed.

When the Continue button is clicked, the value increments while the SRAM address remains unchanged.

Go to Window > Debugging > Disassembly to open the disassembly window and visualize the flow of the instructions.


Notice the highlighted parts of the following code:
- 0x4028A: MOVW R3, #57360
0x4028E: MOVT R3, #57344
The address range for System control space is 0xE000xxxx. From the assembly instructions above for SysTick (where SysTick belongs to System Control Space):
- (57360)2 = 0xE010
- (57344)2 = 0xE000
MOVW R3, #57360 means move wide (loads lower 16 bits of a register 3).
MOVT R3, #57344 means move top (loads upper 16 bits of a register 3).
Therefore, the address of the SysTick will be 0xE000E010, which falls within the range for System Control Space (SCS).
- 0x402A2: MOVW R3, #32884
0x402A6: MOVT R3, #8192
The address range for SRAM is 0x2000xxxx. From the assembly instructions above for SRAM:
- (32884)2 = 8074
- (8192)2 = 2000.
MOVW R3, #32884 and MOVT R3, #8192 together form the address 0x20008074, which lies within the SRAM address range.
- 0x402B8: MOVW R3, #12288
0x402BC: MOVT R3, #16384
The address range for Peripheral (GPIO) is 0x4000xxxx. From the assembly instructions above for SRAM:
- (12288)2 = 3000
- (16384)2 = 4000
MOVW R3, #12288 and MOVT R3, #16384 together produce the address 0x40003000, which falls within the Peripheral address range.
The user LED toggles (switching on and off) when the Continue button is clicked.
