Datasheet
Specific Debug Functions: 32-Bit Devices
2013 Microchip Technology Inc. DS52085A-page 77
EXAMPLE 7-1: APPLICATION IN/OUT MACRO USAGE
The following application code reads the application input register and writes out a
padded value of the input to the application output register.
// include file
#include <p32xxxx.h>
// set up config bits
#pragma config FWDTEN = OFF
// initialize variables
unsigned int val;
int i;
unsigned int oval;
int main(void)
{
while(1)
{
if(_DDPSTATbits.APIFUL) // APPI is full?
{
val = _APPI; // Read User Input
for(i=0; i<4; i++)
{
while(_DDPSTATbits.APOFUL); // APPO is full?
oval = val&0xFF;
if(oval < 0x20)
oval = 0x20;
oval |= 0x20202000;
_APPO = oval; // Send to MPLAB X IDE
val >>= 8;
}
}
}
}
To run this application:
1. Create a project using the Project wizard:
a) Select a supported device.
b) Select REAL ICE or ICD 3 as the hardware tool.
c) Use the “MPLAB C Compiler for PIC32 MCUs” or the “MPLAB XC32 C
Compiler” as the language toolsuite.
2. Select File>New File
to create and name a new C Source File. In the Editor
window that opens, add the previous code and save.
3. Right click on the project name in the Projects window and select “Properties”. In
the Project Properties window, click on “pic32-gcc” under “Categories”. Under
“Option Categories”, select “General” and check the “Enable App IO” checkbox.
4. Build the project (Right click on the project name and select “Build”).
5. Select Window>Debugging>PIC App IO
to open the Application In/Out window.
6. Click on the “Properties” button (on the left of the window) to launch the Set App
IO Properties dialog. Under “Capture” click “On”.