Here you go.
Points to note.
1. I use PGC2/PGD2 because RB0/RB1 (you're twiddling RB0) is shared with PGC1/PGD1.
2. I use the internal FRC oscillator to save any questions over whether your oscillator is working.
3. I assume all power pins are connected include AVDD and AVSS with appropriate decoupling.
4. The oscillator output is available on CLKO: if you have a crystal on that pin, either unsolder it or set OSCIOFNC = OFF. Personally I find having access to CLKO very soothing when getting a device up for the first time.
5. I am using the default FRCDIV which is div-by-4, so as FRC=8MHz, FOSC=2MHz, available on CLKO.
5. I am using the default FRCDIV which is div-by-1, so as FRC=8MHz, Fsys=8MHz. PBCLK1 is derived from this, and by default is Fsys/2. PBCLK1 is further divided by two and available on CLKO (if enabled by OSCIOFNC), hence 2MHz on that pin. These are default settings to avoid complicating things.
6. RB0 toggles at 800kHz and doesn't have a 50% duty cycle. This is due to stalling on the CPU as the GPIO is on a different clock to the CPU. I have not made any attempt to set up cache, wait states or the clock to avoid unnecessary complication.
7. As a rule of thumb I use the predefined bit field structs rather than targeting an entire SFR with a gobbledegook of hex. The exception comes with LATBINV=1 because this is the only way to do a single cycle read-modify-write on an SFR. You could do it in a whole manner of different ways, this is generally recognised as the fastest.
8. Much beyond this, regrettably for these devices you're going to have to use Harmony.
9. Yes, the ADCs on the PIC32MZ EC devices are almost a complete waste of time. The EF devices are infinitely better for this.
10. This was written for a PIC32MZ2048ECH100 on an MA320012 PIM on an Explorer 16 board, but it has been written to be portable across any current PIC32MZ device.
Edit:
11. Do you have a 10k resistor from MCLR to Vdd?
#include <xc.h>
#pragma config FNOSC = FRCDIV // Fast RC Osc w/Div-by-N (FRCDIV)
#pragma config OSCIOFNC = ON // Show clock on CLKO pin
#pragma config POSCMOD = OFF //Primary oscillator off
#pragma config FWDTEN = OFF // Watchdog off
#pragma config FDMTEN = OFF // Deadman Timer is disabled
#pragma config JTAGEN = OFF // JTAG Disabled
#pragma config ICESEL = ICS_PGx2 // PGC2/PGD2
int main(void)
{
TRISBbits.TRISB0=0;
LATBbits.LATB0=1;
while (1)
{
LATBINV=1; // Invert RB0
}
return 0;
}