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.

CCS/LAUNCHXL-CC26X2R1: Calibration of the XOSC_LF clock after boot up

Part Number: LAUNCHXL-CC26X2R1

Tool/software: Code Composer Studio

Hi,

I have LAUNCHXL-CC26X2R1 boards with CCS v9.1.0 and I am using the simplelink_cc13x2_26x2_sdk_3_10_01_11 SDK for project.

I am working on the Simple Peripheral application and have modified the project so it can supports the BIM. In the BIM project, I am trying to calibrate the XOSC_LF clock.

Right now, I have turn off RCOSC_LF clock with statically configuring the Power Manager configuration object. I have included  SET_CCFG_MODE_CONF_SCLC_LF_OPTION 0x03  for LF RCOSC in the ccfg area. In the main, at first I tried to request XoscLf to use TdcRef as shown below :

    // Select XOSC_LF as TDC_REF clock source
    HWREGH( AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_CTL0 ) = ( 3 << DDI_0_OSC_CTL0_ACLK_REF_SRC_SEL_S );

    // Must sync twice to let TDC_REF setting propagate before requesting it
    HWREG( AON_RTC_BASE + AON_RTC_O_SYNC );
    HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ) = 1 ;
    HWREG( AON_RTC_BASE + AON_RTC_O_SYNC );

    // Enable the TDC_REF clock request  
    HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_TDCREFCLKCTL ) = AUX_SYSIF_TDCREFCLKCTL_REQ ;

Then I check if the TdcRef Clk Ready:

IsTdcRefClkReady( void )
{
    //if ( HWREG( AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL ) & AUX_WUC_REFCLKCTL_ACK ) {
    if ( HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_TDCREFCLKCTL ) & AUX_SYSIF_TDCREFCLKCTL_ACK ) {
        return ( 1 );
    }
    return ( 0 );
}

If I ran this sequence through the CCS debug session, it works fine and I am able to run the Simple Peripheral application after BIM.

But if do the hard reset on the board after downloading the program or closing the debug session, it stuck in the IsTdcRefClk() i.e. it always return 0.

I tried debug session to read the register value, there IsTdcRefClk() return 1 i.e. AUX_SYSIF_TDCREFCLKCTL_ACK is getting set in the AUX_SYSIF. Because of this I am unable to figure out why it is behaving like that when debug session is close.

Can you explain why it behaving like that? Let me know what you think.

Regards,

Shiv

  • Hi Shiv, 

    Assigning an expert to comment. 

    Thanks, 
    Elin

  • Hi Shiv,

    Could you elaborate on what the idea behind the implementation are, are you trying to calibrate the XOSC_LF, in that case, what are you calibrating it against?

    Also, why are do you setup to use RCOSC_LF when you seem to have the XOSC_LF mounted and running?

  • Hi M-W,

     The system starts up with the RCOSC_LF clock. Because of which first we let it synchronize with TDC reference clock. And then I am trying to switch from RCOSC_LF to the XOSC_LF as SCLK_LF source in the application. 

    So, I have perform the following steps in the BIM :

    • SET_CCFG_MODE_CONF_SCLC_LF_OPTION 0x03  for LF RCOSC in the ccfg area
    • Set calibrateRCOSC_LF as false in the static Power configuration structure. As there were no structure in the BIM, I have added the files to access the static Power configuration structure and initialize the power manager
    • Request XOSC_LF to use TDC Reference clock
    • Then wait for  TDC reference clock get ready
    • Switch the LF Clock from RCOSC_LF to the XOSC_LF as SCLK_LF source.

    These steps are working fine in the debugging session but after the hard reset AUX_SYSIF_TDCREFCLKCTL_ACK is not able to set.

    Regards,

    Shiv

  • Hi Shiv,

    I don't see why you can't simply set SET_CCFG_MODE_CONF_SCLC_LF_OPTION to always use the XOSC_LF and don't mind the RCOSC_LF when in the BIM? Also, are you doing anything related to precise timing in the BIM today that requires the calibration prior to running the application (which likely is already setup to perform this)?

     As for your TDC code, could you share the full code you use to set it up (with that I mean i small example snippet that I could run)?

  • Hi M-W,

    There is limitation for our project. Due to the power constraint we have to use RCOSC_LF at system startup. And then switch from RCOSC_LF to XOSC_LF as SCLK_LF source.

    The whole sequence is called just after boot up in the BIM. As I meniton I have added the board specific files for initializing the power manager with static power configuration structure (i.e. turn off the calibrateRCOSC_LF ).So, after boot up process, Board_initGeneral function is called which initialize the power manager (power_init()). After which all the steps are performed in sequence as mention in previous comment.And I have remove the power manager initialization(power_init()) from the application, as we are initializing that in the BIM.

    int main(void)
    {
        Board_initGeneral();
    
        RequestXoscLfUsingTdcRef();
        usleep(20000);
    
        while (IsTdcRefClkReady() == 0)
        {
            usleep(10000);
        }

    I am getting stuck in the while loop, as AUX_SYSIF_TDCREFCLKCTL_ACK is not able to set. For RequestXoscLfUsingTdcRef() and IsTdcRefClkReady() code snippets:

    RequestXoscLfUsingTdcRef( void )
    {
        // Select XOSC_LF as TDC_REF clock source
        HWREGH( AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_CTL0 ) = ( 3 << DDI_0_OSC_CTL0_ACLK_REF_SRC_SEL_S );
    
        // Must sync twice to let TDC_REF setting propagate before requesting it
        HWREG( AON_RTC_BASE + AON_RTC_O_SYNC );
        HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ) = 1 ;
        HWREG( AON_RTC_BASE + AON_RTC_O_SYNC );
    
        // Enable the TDC_REF clock request
        HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_TDCREFCLKCTL ) = AUX_SYSIF_TDCREFCLKCTL_REQ ;
    }
    IsTdcRefClkReady( void )
    {
        if ( HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_TDCREFCLKCTL ) & AUX_SYSIF_TDCREFCLKCTL_ACK ) {
            return ( 1 );
        }
        return ( 0 );
    }

    Can you check and let us know the behavior why these steps are working fine in the debugging session but after the hard reset AUX_SYSIF_TDCREFCLKCTL_ACK is not able to set. 

    Regards,

    Shiv

  • Hi Shiv,

    I will take a look at the TDC part and get back to you.

    The rest of your "BIM" is however still confusing. First of all, the BIM as supplied by TI does not run either TI-RTOS or NoRTOS which means you can't use for example the PIN driver or the Power driver/manager.

    As you are doing this, I will only assume that you are running your own bootloader that is based on either NoRTOS or TI-RTOS. In that case, how do you branch to the application? As you say that you later will not do any power initialization in the application because you did it in the BIM I could only assume you are not jumping into the reset routine? Typically the bootloader and application is decoupled in this way, which means you need to do the "init" on both sides (if you also do it in BIM) as they do not share state.

    What I'm trying to understand is what you do in the bootloader that require you to calibrate the RCOSC_LF. Also, if you are already using TI-RTOS / NoRTOS (as you claim to have added int he power manager) , why do you not use the calibration routine that is already included as part of the power manager?

  • Hi M-W,

    " In that case, how do you branch to the application? As you say that you later will not do any power initialization in the application because you did it in the BIM I could only assume you are not jumping into the reset routine? Typically the bootloader and application is decoupled in this way, which means you need to do the "init" on both sides (if you also do it in BIM) as they do not share state. "

    I have added the library files for the NoRTOS in the BIM because of which we are able to initialize the Power Manager. We directly jump to the known address of the Application because of which I think we don't need to again initialize the power manager. And why does it have to run the reset routine, when we are directly jumping the Application from the main() of BIM with the known address of the Application?

    Right now we are not using any precise timing for anything in the BIM. But it can be required in the future. So, we are doing all initialization part in the BIM and later using it in the Application.

    Regards,
    Shiv

  • Hi Shiv,

    So as you seem to be using a NoRTOS BIM, why not simply use the calibration routine implemented in the power manager? 

    As for the application jump part, consider this, do your application (unassumingly a TI-RTOS application?) know anything about the BIM and it's structures? If the application part is compiled as it's own project, it also has it's own idea of the state of things (as the objects/structs storing all of this information, like the power drivers configuration struct, is bound to the compile unit).

    If the application is not told to "use the struct that is found at this location in RAM that you do not know about", the "truth" about the actual state of the system would diverge. This is why you branch to the reset routine of the application. This assure it is started with a clean state, just like in the case where there would be no bootloader.

    Branching into the reset routine is also very important as initializing of variables and data structures defined in the application is also performed from here. 

    To do what you want to do, "sharing" initialization between the BIM and application, you basically would need to make them a single project, which means the "Application" really is just a normal function call and not a free-standing application.