I have a problem when I try to program MCU with 4MHz oscillator. It works when the oscillator is not used.
Vdd: 3.3 V
External oscillator: http://datasheet.octopart.com/ASV-48.000MHZ-EJ-T-Abracon-datasheet-5458457.pdf (4MHz)
External oscillator output: amplitude is ~ 3.2 V (square wave).
Output of the oscillator has a voltage divider with resistors and capacitor. Oscillator gives ~1.95 V amplitude to EXTAL pin.
XTAL is not connected. VDDpll is bypassed to ground.
Code I'm using to program PLL:
// SYNR_SETUP = 0x04 (SYNDIV)
SYNR = SYNR_SETUP;
// REFDV_SETUP = 0x04 (REFFRQ)
REFDV = REFDV_SETUP;
// POSTDIV_SETUP = 0
POSTDIV = POSTDIV_SETUP;
// wait for the PLL to lock into correct frequency
while(!(CRGFLG & CRGFLG_LOCK_MASK));
// CLKSEL_SETUP = 0x80 (PLLSEL)
CLKSEL = CLKSEL_SETUP;
// Check if everything is ok
while(!(CLKSEL & CLKSEL_PLLSEL_MASK));
When oscillator is connected and SetupPLL function is used, the programmer gives verification error @ 0x0000C008.
Also, I have came across with illegal breakpoints and xgate breakpoints. At first I couldn't find the right delay for programming even if automatic delay was used, but when I increased the output voltage from oscillator it started to work. I can use steps until init() functions when it crashes.
When both oscillator and SetupPLL are not used, I can program the MCU without any problems.
I have tried to use signal generator (Vpp 1.8v: 0-1.8 V, 4MHz, same code,) for EXTAL pin, but it didn't work.
If you have any experience about these kind of problems or you could share some ideas how to proceed with this system, I'd be grateful.