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.

TMS320F28035: Issue while configuring external oscillator

Part Number: TMS320F28035
Other Parts Discussed in Thread: C2000WARE

Hello,

I have been using the internal oscillator in my application. I am now trying to switch to the external crystal oscillator. I implemented the code shown below.

When I flash the program for the first time, the system works as expected — the LED blinks and the timer interrupt executes every 1 ms. However, sometimes after flashing, the LED does not blink and the timer interrupt does not execute.

In some cases:

  • The first flash works correctly.
  • After a power cycle, the LED does not blink.
  • Re-flashing the program again does not always resolve the issue.

It appears that the system is not always switching to or running correctly from the external oscillator.

Could you suggest what might be causing this behavior?

I also tried setting INTOSC1OFF = 1, but the behavior remained the same.

 

Below is the code used to select the external oscillator, also I have attced the schematic

 

static void cpu_ExtOsclSel (void)

{

 /* TI - Recommended sequence

 * XTAL - ON - main clock

 * INTOSC1 - ON - backup / debugger safety

 * INTOSC2 - OFF - unused */

 

 EALLOW;

 SysCtrlRegs.CLKCTL.bit.XTALOSCOFF = 0; // External crystal ON (XTALOSC on X1/X2)

 EDIS;

 

 DELAY_US(10000); // Allow crystal to stabilize (~10 ms)

 

 EALLOW;

 SysCtrlRegs.CLKCTL.bit.XCLKINOFF = 1; // Turn off XCLKIN (not used)

 SysCtrlRegs.CLKCTL.bit.OSCCLKSRC2SEL = 0; // 0 = External crystal on X1/X2

 

 SysCtrlRegs.CLKCTL.bit.OSCCLKSRC2SEL = 0; // External oscillator selected

 SysCtrlRegs.CLKCTL.bit.OSCCLKSRCSEL = 1; // 1 = Use source 2 (XTAL or INTOSC2)

 

 SysCtrlRegs.CLKCTL.bit.WDCLKSRCSEL = 0; // WDT clock source = INTOSC1

 SysCtrlRegs.CLKCTL.bit.INTOSC2OFF = 1; // Turn off INTOSC2

 SysCtrlRegs.CLKCTL.bit.INTOSC1OFF = 0; // Keep INTOSC1 ON as backup

 EDIS;

}

 

image.png

Any guidance on what might be causing the intermittent behavior would be appreciated.

 

Thank you.

  • Hello,

    Do you have the ESR of the 20MHZ crystal used?  For this oscillator design, the EST should be around 45ohms to have proper start up

    Regards,

    Jooseph

  • Joseph,

    Crystal used is ECS-200-CDX-0998. 

    Looks like problem is with the delay. Delay function  DELAY_US(10000); uses SYSCLOCK. If I replace this delay with manual delay my program is working

  • Hello,

    ECS-200-CDX-0998 has ESR of 50ohms and within the range of the crystal circuit oscillator.  Yes, you need to allow some delay for the crystal to overcome the ESR and allow for the oscillator circuit to start up properly.

    Regards,

    Joseph

  • Earlier I had included sufficient delay, but I was using the DELAY_US() function, which is also used in the TI example function XtalOscSel(). It appears that this delay function was causing the issue. The problem was resolved after I replaced it with a delay implemented using a for loop.

    The TI example did not work in my case. I am trying to understand how DELAY_US() is used in the TI example before SYSCLK is stabilized. I was referring to the XtalOscSel function in DSP2803x_SysCtrl.c located in:

    c2000\C2000Ware_5_02_00_00\device_support\f2803x\common\source.

  • Thanks for the details.  Can you provide the macro of DELAY_US() in your C2000Ware version?  Just wanted to check if this was changed or not.

    Regards,

    Joseph

  • DELAY_US() is supposed to call a subtraction loop in assembly code and in each loop, takes specific number of cycle count + overhead and result is multiplied by system period to get the corresponding microsecond delay.  This routine is more deterministic in introducing delay in terms of uSec rather than using for loop.