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.

CC2510 high speed oscillators

Other Parts Discussed in Thread: CC2510

Using a CC2510, we're trying to periodically switch from the internal high speed oscillator (HS RSOSC) to the external high speed crystal oscillator.  This is during Active mode, not one of the four low power modes.  Trouble is, it won't work--operation continues with the HS RSOSC.  The settings look right to us...any gotchas when switching between these two oscillators?

  • Todd,

    Please reference the attached code example which is designed for this exact scenario, clk_xosc.c

    /***********************************************************************************
      Filename:     clk_xosc.c
    
      Description:  Change system clock source to High Speed Crystal Oscillator (HS XOSC)
                    and set clock speed to highest clock speed (26 Mhz).
    
    ***********************************************************************************/
    
    /***********************************************************************************
    * INCLUDES
    */
    #include <hal_types.h>
    #include <hal_defs.h>
    #include <hal_cc8051.h>
    #include <ioCCxx10_bitdef.h>
    
    #if (chip == 2510)
    #include <ioCC2510.h>
    #endif
    #if (chip == 1110)
    #include <ioCC1110.h>
    #endif
    #if (chip == 2511)
    #include <ioCC2511.h>
    #endif
    #if (chip == 1111)
    #include <ioCC1111.h>
    #endif
    
    /***********************************************************************************
    * CONSTANTS
    */
    
    
    /***********************************************************************************
    * LOCAL VARIABLES
    */
    
    
    /***********************************************************************************
    * LOCAL FUNCTIONS
    */
    
    
    
    /***********************************************************************************
    * @fn          main
    *
    * @brief       Set clock to HS XOSC at 26 Mhz
    *
    * @param       void
    *
    * @return      0
    */
    
    int main(void)
    {
        /* Select HS XOSC as system clock source and set the clockspeed to 26 Mhz.
           Once the clock source change has been initiated, the clock source should
           not be changed/updated again until the current clock change has finished. */
    
        // Power up unused oscillator (HS XOSC).
        SLEEP &= ~SLEEP_OSC_PD;
    
        // Wait until the HS XOSC is stable.
        while( !(SLEEP & SLEEP_XOSC_S) );
    
        // Change the system clock source to HS XOSC and set the clock speed to 26 MHz.
        CLKCON = (CLKCON & ~(CLKCON_CLKSPD | CLKCON_OSC)) | CLKSPD_DIV_1;
    
        // Wait until system clock source has changed to HS XOSC (CLKCON.OSC = 0).
        while (CLKCON & CLKCON_OSC);
    
        // Power down the HS RCOSC, since it is not beeing used.
        // Note that the HS RCOSC should not be powered down before the applied
        // system clock source is stable (SLEEP.XOSC_STB = 1).
        SLEEP |= SLEEP_OSC_PD;
    
        /* Continue... */
    
        return 0;
    }
    
    
    /***********************************************************************************
      Copyright 2008 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    ***********************************************************************************/
    

    Also, I encourage you to also have a look at another code example for initializing the High Speeed Oscillator.

    /***********************************************************************************
      Filename:     clk_hfrc.c
    
      Description:  Set system clock source to High Speed RC oscillator (HS RCOSC)
                    and set system clock speed = 3.25 Mhz.
    
    ***********************************************************************************/
    
    /***********************************************************************************
    * INCLUDES
    */
    #include <hal_types.h>
    #include <hal_defs.h>
    #include <hal_cc8051.h>
    #include <ioCCxx10_bitdef.h>
    
    #if (chip == 2510)
    #include <ioCC2510.h>
    #endif
    #if (chip == 1110)
    #include <ioCC1110.h>
    #endif
    #if (chip == 2511)
    #include <ioCC2511.h>
    #endif
    #if (chip == 1111)
    #include <ioCC1111.h>
    #endif
    
    /***********************************************************************************
    * CONSTANTS
    */
    
    
    /***********************************************************************************
    * LOCAL VARIABLES
    */
    
    
    /***********************************************************************************
    * LOCAL FUNCTIONS
    */
    
    
    
    /***********************************************************************************
    * @fn          main
    *
    * @brief       Set system clock source to HS RCOSC @ 3.25 MHz
    *
    * @param       void
    *
    * @return      0
    */
    
    int main(void)
    {
        /* Initially, the HS RCOSC (HFRC) is not calibrated.
           To do so, the system clock source must be changed to the HS XOSC.
           Once the system clock source is HS XOSC then the chip will start
           calibrating both the HS RCOSC and low power LS RCOSC. The HS RCOSC
           calibration takes about 65 us, while the LS RCOSC calibration takes
           about 2 ms.
    
           The following is not possible before calibration is completed:
            - Changing system clock source back to HS RCOSC.
            - Entering PM {1-3}.
            - Power down HS RCOSC (SLEEP.OSC_PD = 1).
           Hence, it will take about 2.065 ms before the system clock source can
           be changed back to HS RCOSC.
    
           If the HS RCOSC is powered down after calibration, then the calibration
           value is stored and used when the HS RCOSC is powered up again. */
    
    
        // This code section changes the system clock source to the HS XOSC:
    
        /////////////////////////////////////////////////////////////////////////
        ///////////////////////// Code section begin ////////////////////////////
    
        // Power up unused oscillator (HS XOSC).
        SLEEP &= ~SLEEP_OSC_PD;
    
        // Wait until the HS XOSC is stable.
        while( !(SLEEP & SLEEP_XOSC_S) );
    
        // Change system clock source to HS XOSC.
        CLKCON &= ~CLKCON_OSC;
    
        // Wait until system clock source has changed to HS XOSC (CLKCON.OSC = 0).
        while ( CLKCON & CLKCON_OSC ) ;
    
        ///////////////////////// Code section end //////////////////////////////
        /////////////////////////////////////////////////////////////////////////
    
    
    
        // This code section changes the system clock source back to the HS RCOSC:
    
        /////////////////////////////////////////////////////////////////////////
        ///////////////////////// Code section begin ////////////////////////////
    
        // Note that at this point in time the HS RCOSC is already powered up
        // and stable, so it is not necessary to execute that instruction here.
    
        // Change system clock source to HS RCOSC and set clock speed = 3.25 MHz.
        CLKCON = (CLKCON & ~CLKCON_CLKSPD) | CLKCON_OSC | CLKSPD_DIV_8;
    
        // Wait until the system clock source has indeed changed to HS RCOSC.
        // Once [CLKCON.OSC = 1] this now confirms all of the following statements:
        //  - Initial calibration of the HS RCOSC and LS RCOSC has completed.
        //  - The desired system clock source is stable (SLEEP.HFRC_STB = 1).
        //  - The desired system clock source change has taken effect.
        while ( !(CLKCON & CLKCON_OSC) ) ;
    
        // Power down the HS XOSC, since it is not beeing used.
        // Note that the HS XOSC should not be powered down before the applied
        // system clock source is stable (SLEEP.HFRC_STB = 1).
        SLEEP |= SLEEP_OSC_PD;
    
        ///////////////////////// Code section end //////////////////////////////
        /////////////////////////////////////////////////////////////////////////
    
        /* Continue... */
    
        return 0;
    }
    
    
    /***********************************************************************************
      Copyright 2008 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    ***********************************************************************************/
    

    Both of these code examples can be found in the source\examples\clk folder within the CC1110, CC2510 Basic Software Examples found on the CC2510 product folder page.

    CC1110, CC2510 Basic Software Examples: http://www.ti.com/litv/zip/swrc117 

    Let me know if you need anything else.

  • Thanks for the tips, Austin.

    In our application, we use the radio right after system startup without problems.  After a sleep cycle, we wake the chip to check for changes in a sense input, and use the HS RCOSC to do so.  If the settings have changed, we switch back to the HS XOSC in order to use the radio.  Our code looked much like what is in the referenced examples, but the radio would not work.  What corrected the problem was changing bits in the CLKCON register in multiple instructions instead of a single instruction.  The bits of interest are:

     Bit 6 (OSC), the system clock oscillator select

     Bits 2-0 (CLKSPD[0:2]), the system clock speed setting

     Changing the OSC in one line of code, then the speed setting in a subsequent line, corrected the issue.  We don't know why, but it works.