This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294KCPDT: How to check the External oscillator and switch the clock source when main oscillator fail

Part Number: TM4C1294KCPDT

Hello everyone:

The function I want to design is when MCU lose the main external oscillator, it could switch the Clock source to Internal Clock source 、keep the code running i and get the external main oscillator fault flag

The following are the ways I tried:

1、Detect the register MOSCCTL (I don't set any bit of it), when the code is running, the bit OSCRNG(High Frequency Range (equal to or greater than 10 MHz).) was 1 when the rest were 0. After I cut off the external oscillator, the code jump into Hard_fault handler automatically and register MOSCCTL didn't has any changes.

2、When I used j-link simulator to simulate the MCU, I cut off the external oscillator. In most case, the code will jump to Hard_Fault Handler, but sometimes it will jump to bus_fault or memery_fault. What's more, when code jump into hard_fault handler, it need me to click single step run the code, it can't run in full speed and sometimes it even didn't run and register PC  didn't count when I click single step. So it 's difficult to me to judge whether the MCU was still working.

3、I have some idea that when the external oscillator fail, it could reboot the MCU and when it decides which clock source to use according to bit MOSCPUPIM in register IMC and set a flag which means MCU lost external oscillator last time when it initialize the MCU. There are 2 defects, one is when it repower MCU, the bit  MOSCPUPIM  will be clear; two is when clock fault happen,it don't have time to do the emergency operation such as control GPIO to cut off some breaker.

It is very kind of you if you have any ideas could share to me.

Thank you all

  • First did you enable the main oscillator monitor (CVAL bit of MOSCCTL register)? Did you select the interrupt or NMI on oscillator fault (MOSCIM bit)? Did you configure the NMI or interrupt routine?

  • I have not heard back from you so I assume that you have resolved this issue. If not, just reply to this thread or ask a related question.

  • Hi Bob:

    I'm sorry for replying you so late because I have another emergency issue need to fixed. I decide to active clock detection circuit , if external oscillator  failed,bit MOSCPUPIM in register IMC will be set, after the MCU reboot, I will select the internal oscillator as clock source according to the bit MOSCPUPIM when the  MCU is at initial state and set a warning to remind user external ocillator doesm't work now.

    best regards

    Jay Wang