Hello,
I have a s08JM60 I am trying to use the usb module on, and one of the requirements is that I have an external clock so I can have a 24Mhz bus clock. I have app note AN3560 which has code for an external 12Mhz crystal, which is what I have. But when I run the MCG_Init() it errors out with an ILLEGAL BP. Once I get this error I can not reconnect to the chip without a reset. I get an unable to execute command.
Here is the code from the app note.
void MCG_Init(){/* the MCG is set to FEI mode by default, it should be change to FBE mode at first */MCGC2 = 0x36; /*Select high frequency, high gain, Oscillator requested*/while(!(MCGSC & 0x02)); /*Wait for the stable of Oscillator */MCGC1 = 0x9B; /*External clock is selected, RDIV = 0b011 (to get 1.5MHz)*/while((MCGSC & 0x1C) != 0x08); /*Check whether the external reference clock is selected */ /* Switch to PBE mode from FBE*/MCGC3 = 0x48; /*Enable PLL, VDIV = 0b1000, multiply by 32*/while ((MCGSC & 0x48) != 0x48); /*Wait for the PLL to be locked */ /*Switch to PEE mode from PBE mode*/MCGC1 &= 0x3F; /*PLL output is selected*/while((MCGSC & 0x6C) != 0x6C); /*Wait for the PLL output becoming the system clock source */return;}
The error starts at either the MCGC1 &= 0x3F;
or
while((MCGSC & 0x6C) != 0x6C);
Could wrong value capacitors cause this? It does kick start crystal as I can see a 12Mhz signal on the scope.
Travis
Added p/n to subject.
Message Edited by NLFSJ on 2009-04-16 09:17 AM