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.

TMS320F28069M: Setting up external clock source

Part Number: TMS320F28069M
Other Parts Discussed in Thread: C2000WARE, MOTORWARE

Hi,

Using a modified Lab06a, I'm struggling to setup the use of an external clock source on GPIO 19. All my efforts so far have left with an unstable application: i.e. random Illegal ISRs or lockups. Can anyone suggest whats going wrong?...

Code has been modified in two areas: 

HAL_SetupClks()
{
    //configure clkin pin as GP 
    GPIO_setMode(obj->gpioHandle, PIN_XCLK_IN, GPIO_MODE_GENERAL_PURPOSE);
    GPIO_setDirection(obj->gpioHandle, PIN_XCLK_IN, GPIO_Direction_Input);

    //enable the clk-in pin
    CLK_setXClkInSrc(obj->clkHandle, CLK_XClkInSrc_Gpio19);
    CLK_enableClkIn(obj->clkHandle);
    // set the oscillator source
    CLK_setOscSrc(obj->clkHandle, CLK_OscSrc_External);
    // disable the crystal oscillator
    CLK_disableCrystalOsc(obj->clkHandle);
    // disable oscillator 2
    CLK_disableOsc2(obj->clkHandle);
    // set the low speed clock prescaler
    CLK_setLowSpdPreScaler(obj->clkHandle, CLK_LowSpdPreScaler_SysClkOut_by_1);
    // set the clock out prescaler
    CLK_setClkOutPreScaler(obj->clkHandle, CLK_ClkOutPreScaler_SysClkOut_by_1);
}

Then the HAL_setupPLL() function keeps the PLL at div/4

PLL_setDivideSelect(obj->pllHandle, PLL_DivideSelect_ClkIn_by_4);

The clock source I'm using is a 20MHz silicon oscillator, connected to GPIO19. Scoping the clock source shows its 'ok' - no major noise or deviations. 

Any ideas?

Mat

  • Hi Mat

    I will be taking a look at this issue and hope to have an answer from someone within TI soon

    Sean
  • Mat,
    As a first step in debug, could you please run any example in C2000ware? The exact example is not important, but in your code, please call the ExtOscSel(void) function in the F2806x_SysCtrl.c file, which is present in C:\ti\c2000\C2000Ware_1_00_05_00\device_support\f2806x\common\source. This is a tested function and should work.
  • Mat,
    Please provide a status update. If this is resolved, please close the post.
  • Alas, its still not resolved. 

    I followed the example: this helped identify a couple of issues, but I'm still getting peripheral errors and illegal ISRs. 

    I think the main problem may be the use of a 20MHz clock vs the internal 10MHz one: something isn't correctly setup and I haven't found where yet. To be frank, I'm struggling to follow the chips clocking scheme - I suspect I'm setting the CPU frequency correctly but some of the peripherals are attached pre-scaler and therefore running twice as fast as they should. Haven't identified where...

    Mat

     

  • A clock input of 20 MHz, in itself, should not cuase a problem. If you feel your code doesn’t account for the change in i/p frequency correctly, perhaps you could change your external clock frequency from 20 MHz to 10 MHz and check if your code works correctly. (10 MHz is the frequency of INTOSC and it appears your code works fine with INTOSC)

     

    Check the XCLKOUT frequency to ensure the SYSCLKOUT frequency is the expected frequency. Fig 1-19 and 1-23 in SPRUH18G clearly illustrates all the registers/bits at play in configuring the clock.

     

    While communication errors are to be expected if the clock is not configured correctly, the fact that you are experiencing illegal ISRs makes me wonder if you are running the device in excess of 90 MHz. If the SYSCLKOUT frequency is the same (independent of the clock source), then there is no need to tweak the clock prescalers preceding the peripherals.

     

  • A little further forward, but still no success.

    I re-verified the config and change OSC2 back to internal (for use as a fallback). In this instance the application runs but inspection of pll->PLLSTS reveals 0x40 - PLL CLOCK MISSING.

    Will try to externalize the clock and see whats going on...

    Mat
  • 0x40 does not imply “PLL clock missing”. Could you please provide the correct 16-bit value of PLLSTS register? Can you provide a scope shot of the clock at GPIO19? Are you able to run a C2000ware example “as is” with the external clock? You could pick a CPU-Timer example.
    • Is the X1 pin tied to GND?
    • Could you provide the schematics of your design? Not the whole thing, just the parts connected to X1/X2 & XCLKIN pins.

     

    Please try this sequence:

    1. Run the CPU-Timer example (Example_2806xCpuTimer) from C2000Ware "as is"
    2. Run the same example with the clock source switched to XCLKIN

  • Hi Hareesh,

    Running the C2000Ware example 'as is' isn't straight forward due to the custom board and motorware support. However, I've got some new oscillators on order: so I can try two things: 

    1. Connect 20MHz to the Launchpad, running example code

    2. Connect 10MHz to our board, running motorware, etc. 

    I will also send you the full register info: alas I've run out of time today to do this!

    Schematic snippet below.

    Mat

    Hi Hareesh,

  • Mat,
    I don’t know the details of your hardware, but C2000Ware examples are self-contained and run-off RAM. If you disable all the peripheral clocks (except the CPU-timer clocks), and run the example, you should be able to run it without disturbing any hardware connected on your board.

    Clock switching should be fairly straightforward. Perhaps there is some subtle error in the code that we are missing (an absent EALLOW, for example)
  • It seems trying a C2000Ware example isn't that straight forward using CCSv8: got all sorts of compiler issues to resolve!
    Alas every time I sit down to work on this problem, I get called off on another issue, so it's probably best if I close this request now: up to the point I can get a new 10MHz oscillator fitted and determine whether its an external clock issue or a frequency issue.
     
    Thanks for your help.