// PIC32MX220F032B Configuration Bit Settings
// PIC32MX220F032B Configuration Bit Settings
#include <p32xxxx.h>
// DEVCFG3// USERID = No Setting
#pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration (Allow only one reconfiguration)
#pragma config IOL1WAY = ON // Peripheral Pin Select Configuration (Allow multiple reconfigurations)
#pragma config FUSBIDIO = ON // USB USID Selection (Controlled by the USB Module)
#pragma config FVBUSONIO = ON // USB VBUS ON Selection (Controlled by USB Module)
// DEVCFG2
#pragma config FPLLIDIV = DIV_1 // PLL Input Divider (1x Divider)
#pragma config FPLLMUL = MUL_16 // PLL Multiplier (16x Multiplier)
#pragma config UPLLIDIV = DIV_12 // USB PLL Input Divider (12x Divider)
#pragma config UPLLEN = OFF // USB PLL Enable (Disabled and Bypassed)
#pragma config FPLLODIV = DIV_16 // System PLL Output Clock Divider (PLL Divide by 16)
// DEVCFG1
#pragma config FNOSC = FRCDIV // Oscillator Selection Bits (Fast RC Osc w/Div-by-N (FRCDIV))
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled)
#pragma config IESO = ON // Internal/External Switch Over (Enabled)
#pragma config POSCMOD = HS // Primary Oscillator Configuration (HS osc mode)
#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled)
#pragma config FPBDIV = DIV_4 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/4)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576)
#pragma config WINDIS = OFF // Watchdog Timer Window Enable (Watchdog Timer is in Non-Window Mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls))
#pragma config FWDTWINSZ = WISZ_25 // Watchdog Timer Window Size (Window Size is 25%)
// DEVCFG0
#pragma config JTAGEN = OFF // JTAG Enable (JTAG Disabled)
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select (Communicate on PGEC1/PGED1)
#pragma config PWP = OFF // Program Flash Write Protect (Disable)
#pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled)
#pragma config CP = OFF // Code Protect (Protection Disabled)
#define PPSUnLock() {SYSKEY=0x0;SYSKEY=0xAA996655;SYSKEY=0x556699AA;CFGCONbits.IOLOCK=0;}
#define PPSLock() {SYSKEY=0x0;SYSKEY=0xAA996655;SYSKEY=0x556699AA;CFGCONbits.IOLOCK=1;}
void main()
{
unsigned int i;
unsigned int j=0x000001;
ANSELB=0;
PPSUnLock();
CFGCONbits.IOLOCK=0;
TRISBbits.TRISB3=0;
RPB3Rbits.RPB3R=1;
TRISBbits.TRISB2=1;
U1RXRbits.U1RXR=4;
PPSLock();
U1MODEbits.UEN=0;
U1MODEbits.ON=1;
U1MODEbits.SIDL=0;
U1MODEbits.IREN=0;
U1MODEbits.WAKE=0;
U1MODEbits.LPBACK=0;
U1MODEbits.ABAUD=0;
U1MODEbits.BRGH=1;
U1MODEbits.PDSEL=0;
U1MODEbits.STSEL=0;
U1MODEbits.RXINV=0;
U1STAbits.URXISEL=0;
U1STAbits.UTXISEL=0;
U1STAbits.URXEN=1;
U1STAbits.UTXBRK=0;
U1STAbits.UTXEN=1;
U1STAbits.UTXBF=0;
U1STAbits.TRMT=0;
U1STAbits.ADDEN=0;
U1STAbits.UTXINV=0;
U1BRG=10;
while(1)
{
while (U1STAbits.UTXBF); // wait until transmit buffer empty
U1TXREG=j;
j=j+1;
for(i=0;i<32750;i++); //Provide a random delay
for(i=0;i<32750;i++);
for(i=0;i<32750;i++);
for(i=0;i<32750;i++);
for(i=0;i<32750;i++);
for(i=0;i<32750;i++);
}
}