Hi Big!!
Those values were calculated following the example in the datasheet (8.5.3), but edited for my needs:
Ficg=Fext*P*N/R; P=1, Fext=8M, Ficg=16M
N/R=Ficg/(Fext * P)=16M/8M=2
so N=MFD=16 and R=RFD=8, did I something wrong?? ... Yes something is very bad, but I have corrected to this
ICGC2=0b00000001;
with N=4 and R=2

... but

it is still not working. I've visited the link you told me, but doesn't say which was the final code, so I cannot follow it =( I feel that guy was talking to himself

I'm writing each of the two registers as a byte, so I guess there is not problem with that.
In one pin of the crystal I have 0V and in the other 5V and the distance from the crystal to the chip is aprox 0.375 in, and both are in the same plane, and the caps are 39 pF
Using PE as an experiment, in the very first rutine when the debugger reaches the line 6 the it lost its track and resets, which makes me think that the crystal is not working in anyway
1 void _EntryPoint(void)
2 {
3 ... /* some init code */
4 /* System clock initialization */
5 /* ICGC1: HGO=0,RANGE=1,REFS=0,CLKS1=1,CLKS0=0,OSCSTEN=1,LOCD=0,??=0 */
6 setReg8(ICGC1, 0x54);
7 /* ICGC2: LOLRE=0,MFD2=0,MFD1=0,MFD0=0,LOCRE=0,RFD2=0,RFD1=0,RFD0=0 */
8 setReg8(ICGC2, 0x00);
9 ... /* some other init code */
10 while(!ICGS1_ERCS) { /* Wait until external reference is not stable */
11 }
How can I tell the CPU to conect the PTG5..6 to work as a input/output crystal??