Your placement is fine.
Your routing of the crystal signal traces is fine.
Your grounding is bad. Fortunately, doing it better actually makes your PCB design easier. There will be significant high frequency content in the microcontroller return currents and the currents thru the crystal caps. These should be contained locally and NOT allowed to flow accross the main ground plane. If you don't avoid that, you don't have a ground plane anymore but a center-fed patch antenna.
Tie all the ground immediately associated with the micro together on the top layer. This includes the micro's ground pins and the ground side of the crystal caps. Then connect this net to the main ground plane in only one place. This way the high frequency loop currents caused by the micro and the crystal stay on the local net. The only current flowing thru the connection to the main ground plane are the return currents seen by the rest of the circuit.
For extra credit, so something similar with the micro's power net, place the two single feed points near each other, then put a 10 µF or so ceramic cap right between the two immediately on the micro side of the feed points. The cap becomes a second level shunt for high frequency power to ground currents produced by the micro circuit, and the closeness of the feed points reduces the patch antenna drive level of whatever escapes your other defenses.
For more details, see https://electronics.stackexchange.com/a/15143/4512.
Added in response to your new layout:
This is definitely better in that the high frequency loop currents are kept of the main ground plane. That should reduce overall radiation from the board. Since all antennas work symmetrically as receivers and transmitters, that also reduces your susceptibility to external signals.
I don't see the need to make the ground trace from the crystal caps back to the micro so fat. There is little harm in it, but it is not necessary. The currents are quite small, so even just a 8 mil trace will be fine.
I really don't see the point to the deliberate antenna coming down from the crystal caps and wrapping around the crystal. Your signals are well below where that will start to resonate, but adding gratuitous antennas when no RF transmission or reception is intended is not a good idea. You apparently are trying to put a "guard ring" around the crystal, but gave no justification why. Unless you have very high nearby dV/dt and poorly made crystals, there is no reason they need to have guard rings.
If you meant to set those bits as binary, you need to change this:
OSCCONbits.NOSC = 000;
to this:
OSCCONbits.NOSC = 0b000;
Also wherever you set NOSC
back, it should be set to 0b011
not just 011
.
A prefix of "0" actually makes the value octal in the XC32 compiler (as pointed out by @Lundin in comments), which is decimal 9, which == 0b1001, so this is certainly one problem that needs fixing.
Also, in the PIC32 Peripheral Library Guide it says:
"In general when switching to a higher CPU clock frequency the Peripheral Bus divisor should be set to the new lower value before changing the CPU frequency"
So, when going up/down speeds, you should be using the appropriate order of the following calls:
OSCConfig(OSC_FRC, 0, 0, OSC_FRC_POST_1);
mOSCSetPBDIV(OSC_PB_DIV_1);
Best Answer
Neither the 4060 nor the 4521 will get you to a 1Hz output from a 32768 Hz crystal by itself.
You need a division of 2^15. The least a 4521 will divide by is 2^17. The most a 4060 will divide by is 2^14, which needs another /2 from some suitable source. You could use an HC74, or CD4013, or one stage of an HC393 or 390, there are a lot of different ICs that will give you an extra /2 function.
Neither the 4060 nor the 4521 are programmable. They both divide by different numbers, and put all those outputs on the output pins simultaneously. You select which frequency you want by choosing the pin to take the output from. You could do this with a multiplexer if you wanted electronic control of the output frequency.