Hi
There is a batch of MKM34256 work well for a long time, but few of them got a problem which the oscillator cannot be initialized correctly sometime. The code is stuck in following line:
if (MCG_C2 & MCG_C2_EREFS0_MASK) { WAIT_FOR_FLAG (MCG_C2, EREFS0, OSCINIT0); }
Please let me know if you know the reason of this issue.
Thank you very much!
Martin
Hello @martinzhang
I hope you are doing well!
From the description, it seems that the external crystal/resonator is not being able to get the sufficient stability or number of clock cycles in certain units. See this section below.
I am thinking in the following things:
What is the frequency of your external crystal or resonator? This to will also give us opportunity to review the oscillator circuitry according to Table 36-2 of the RM.
When the MCU gets stop at oscillator initialization , did it have low power mode setting/transition ; transition of MCG mode ; or was coming out of a Power on cycle?
This app note Crystal Oscillator Troubleshooting Guide could also be worthy for our trouble shooting task . Here is an excerpt , that is related to the hypothesis that I mentioned above.
Please accept my apologies for the delay
Diego.
Hello Diego,
Thank for your reply and this is very helpful.
Following is the crystal circuit.
Now, all the devices work well and I will check it when this issue come again.
Best Regards,
Martin
If the 22 pF capacitors and all the layout parasitics balance out perfectly such a circuit will not start, the 1M resistor is there to fix this.
The odds of this are small, except for Murphy's Law saying otherwise.
If it continues to be a problem replace one of the caps with one of a slightly different value.
Some chips have internal caps that can be enabled. Don't enable those at the same time as external ones.
The caps should match the loading specified by the crystal manufacture.