- Code: Select all
//#include <p32xxxx.h> // for C32
#include <xc.h> // for XC32
#pragma config FPLLIDIV = DIV_2 // PLL Input Divider
#pragma config FPLLMUL = MUL_20 // PLL Multiplier
#pragma config UPLLIDIV = DIV_2 // USB PLL Input Divider (POSC = 8 Mhz, USB must be supplied with 4 Mhz)
#pragma config UPLLEN = ON // USB PLL Enabled
#pragma config FPLLODIV = DIV_1 // System PLL Output Clock Divider
#pragma config FNOSC = PRIPLL // Oscillator Selection - primary OSC w/Pll (XT+,HS+,EC+PLL)
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable (KLO was off)
#pragma config IESO = OFF // Internal/External Switch-over
#pragma config POSCMOD = HS // Primary Oscillator Configuration - HS osc mode
#pragma config OSCIOFNC = OFF // CLKO Output signal active on the OSCO Pin
#pragma config FPBDIV = DIV_2 // Peripheral Clock divisor
#pragma config FCKSM = CSDCMD // Clock Switching & Monitor Selection - Clk Switch enable, FSCM disable
#pragma config WDTPS = PS1 // Watchdog Timer Postscale - 1:1
#pragma config FWDTEN = OFF // Watchdog Timer Enable
#pragma config CP = OFF // Code Protect
#pragma config BWP = OFF // Boot Flash Write Protect
#pragma config PWP = OFF // Program Flash Write Protect
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select
#pragma config DEBUG = ON // Background Debugger Enable
int main ( void )
{
TRISDbits.TRISD6 = 0; // LED 1
TRISGbits.TRISG6 = 0; // LED 2
while (1) {
LATDbits.LATD6 = 1;
LATGbits.LATG6 = 0;
}
}
It runs successfully when is compiled with C32 compiler and goes into an endless reboot cycle, when is compiled with XC32. I didn't change anything in both compilers' settings. But there must be a subtle difference between them that affects my program. Or it's just a pure black magic.
I certainly can go along with an older C32, but I want to test Harmony framework, and it supports only XC32, as far as I know. Btw, when I load a sample harmony project (CDC), MCU doesn't go into reboot, but it just ignores my code and always fires both LEDs, even if I force them to be off in the program.
MplabX version: 3.60
XC32 version: 1.43