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.

RM57L843: DCC - Using Counter1 as reference

Part Number: RM57L843

Hello,

We are configuring the DCC module to use counter1 as reference for measuring the clock source of counter0. The DCC freezes the counters when the counter1 reaches zero.

The test is working, but sometimes the the status turns to 1 when counter1 is 1 instead of 0. Any thoughts about that?

Regards,

Marcio

  • Hi Marcio,

    I am suspecting this issue is due to the Errata DCC#24:

    *RM57Lx Microcontroller Silicon Errata (Silicon Revision B) (Rev. B) (ti.com)

    Are you using in single shot mode?

    --

    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    It seems a different issue because we are setting DCC1 to stop when the counter 1 reaches 0, as described in "Freezing Counters when Counter1 Reaches Zero:" section 15.2.2 of SPNU562A–March 2018.

    In the picture we can see the Stat=1 (fail) Cnt0 != 0 and Cnt1=1. I would expect to see Stat=2 (done) Cnt0 != 0 and Cnt1=0 .

    Best regards,
    Marcio.

     

  • Hi Marcio,

    Can i get your complete project, can you please zip it and attach it. This would really be helpful for me to easily debug the issue at my end.

    You can even send through private message.

    --

    Thanks & regards,
    Jagadish.

  • Thanks Jagadish.

    I can give you the piece of code related to the test.

    typedef unsigned short WORD;
    typedef unsigned int DWORD;
    
    // DCC Clock0 Counter Seed value configuration (ONCIN=16MHz).
    // Maximum Detection Time (MDT) = 2500 microseconds = (2.5*10^-3)seconds
    // CNT0_SEED = (OSC x MDT) = (16*10^6) * (2.5*10^-3) = 40000
    const DWORD CNT0_SEED = 40000U;
    // DCC Clock1 Counter Seed value configuration (EXTCLKIN1=1MHz).
    // Maximum Detection Time (MDT) = 2500 microseconds = (2.5*10^-3)seconds
    // CNT1_SEED = (EXTCLK1 x MDT) = (1*10^6) * (2.5*10^-3) = 2500
    const DWORD CNT1_SEED = 2500U;
    // DCC Clock0 Counter Seed value configuration (ONCIN=16MHz).
    const DWORD DCC_CNT0_SEED_VALUE = (2 * CNT0_SEED)-4;
    // DCC Clock0 Valid Counter Seed value configuration.
    const DWORD DCC_VALID0_SEED_VALUE = 4U;
    // DCC Clock1 Counter Seed value configuration (EXTCLKIN1=1MHz).
    const DWORD DCC_CNT1_SEED_VALUE = CNT1_SEED;
    // Clock Drift (55ppm for 16MHz)
    // Variation [in Hz] = (frequency [in Hz] * frequency variation [in ppm]) / 10^6
    // Variation [in Hz] = ((16*10^6) * (55)) / 10^6 = 880Hz
    // Maximum Detection Time (MDT) = 2500 microseconds = (2.5x10^-3)seconds
    // CLOCK0_COUNTER_OFFSET = (Variation x MDT) = (880 * (2.5x10^-3)) = 2.2
    //const WORD CLOCK0_COUNTER_OFFSET  = (DWORD)2U;
    const WORD CLOCK0_COUNTER_OFFSET  = (DWORD)50U;
    //DCC Clock0 Counter: Default Value and Thresholds.
    const WORD CLOCK0_COUNTER_DEFAULT = (DWORD)(CNT0_SEED);                                        // Default value.
    const WORD CLOCK0_COUNTER_LOWER   = (DWORD)(CLOCK0_COUNTER_DEFAULT - CLOCK0_COUNTER_OFFSET);   // Lower bound.
    const WORD CLOCK0_COUNTER_UPPER   = (DWORD)(CLOCK0_COUNTER_DEFAULT + CLOCK0_COUNTER_OFFSET);   // Upper bound.
    
    
    void StartTest (void)
    {
      // Configure DCC1.
    
      // Configure the clock sources.
      REG_DCC_1->CNT0CLKSRC = DCC1_CNT0_CLKSRC_OSCIN;
      REG_DCC_1->CNT1CLKSRC = DCC1_CNT1_CLKSRC_EXTCLKIN1;
    
      // Set counters seeds.
      REG_DCC_1->CNT0SEED = DCC_CNT0_SEED_VALUE;
      REG_DCC_1->VALID0SEED = DCC_VALID0_SEED_VALUE;
      REG_DCC_1->CNT1SEED = DCC_CNT1_SEED_VALUE;
    
      // DCC1 Global Control Register configuration.
      REG_DCC_1->GCTRL = (DWORD)0x5U |                  // Disable DCC1.
                         (DWORD)((DWORD)0x5U <<  4U) |  // Disable Error Interrupt.
                         (DWORD)((DWORD)0xBU <<  8U) |  // Enable Single Shot mode.
                         (DWORD)((DWORD)0x5U << 12U);   // Disable Done Interrupt.
    
       // Clear the Done and Error flags.
       REG_DCC_1->STAT = 0x03;
       // Enable DCC1.
       REG_DCC_1->GCTRL = (REG_DCC_1->GCTRL & 0xFFFFFFF0U) | 0xAU;
    }
    
    void TestWorker (void)
    {
        DWORD status = REG_DCC_1->STAT;
        if (status > 0)
        {
            DWORD counter0 = Dcc1GetCounter0();
            DWORD counter1 = Dcc1GetCounter1();
    
            // Test.
            if ((counter0 <= CLOCK0_COUNTER_UPPER) && (counter0 >= CLOCK0_COUNTER_LOWER))
            {
                // Good
                // Clear the Done and Error flags.
                REG_DCC_1->STAT = 0x03;
                // Enable DCC1.
                REG_DCC_1->GCTRL = (REG_DCC_1->GCTRL & 0xFFFFFFF0U) | 0xAU;
            }
            else
            {
                // Error.
                FatalError();
            }
        }
    }
    

  • Hi Marcio,

    Thanks for the code.

    My apologies for the delay, i am out of office and i will be back to office on Monday. I hope it wouldn't be a problem from your end.

    --

    Thanks & regards,
    Jagadish.

  • No problem Jagadish.

  • Hi Marcio,

    I am back from vacation, i started to recreate the issue at my end. I will try to provide an update ASAP.

    --

    Thanks & regards,
    Jagadish.

  • Hi Marcio,

    Appreciated your patience, today i started to test this issue and will try to provide an update by tomorrow.

    --

    Thanks & regards,
    Jagadish.

  • Hi Marcio,

    Apologies for the delay in my response!

    Here is an update from my side.

    I tested with same settings as yours on my RM57L853 Launchpad 

    Here is my tested code:
    DCC_TEST_RM57.zip

    And in this code i also generated 1MHZ on board with ETPWM1A, and i connected same signal to the EXTCLKIN1 and used it for DCC.

    And here is the debug result:

    I tested almost 20 times and i got the same result and i couldn't see Cnt1 value as "1".

    So, i want to check with below things with you:

    1. How frequently you are getting Cnt1 value as 1, out of how many times you are getting this behavior?

    2. From where you are applying 1MHz signal?

    3. Can you please test my code and let me know the result; you just need to short the D9 (ePWM1A) pin of the controller with B5 (EXTCLKIN1).

    --

    Thanks & regards,
    Jagadish.

  • Thanks for you response Jagadish.

    1. How frequently you are getting Cnt1 value as 1, out of how many times you are getting this behavior?

    Approximately 1 time every 30s the status turns to 1 when counter1 is 1 instead of 0. We left the test running repeatedly until the error happens.

    2. From where you are applying 1MHz signal?

    EXTCLKIN1 is an independent chrystal oscillator of a 1MHz. OSCIN is 16MHz chrystal .

    Is the ETPWM1A output synchronised with the OSCIN?

    3. Can you please test my code and let me know the result; you just need to short the D9 (ePWM1A) pin of the controller with B5 (EXTCLKIN1).

    Ok. I´ll do it and return the result to you.

    Thanks and regards,
    Marcio.

  • Hello,

    I ran tests in the LauchPad board connecting EXTCLKIN1 to ePWM1A and also connecting EXTCLKIN1 to a waveform generator.

    First I ran your program. It only compares EXTCLKIN1 and OSCIN once. 

    Then I´ve modified the program to repeat the comparison indefinitely.

    I could not reproduce the same problem I saw with my application in our board.

    Thank you very much for the support.

    Marcio

  • Hi Marcio,

    also connecting EXTCLKIN1 to a waveform generator.
    I could not reproduce the same problem I saw with my application in our board.

    So, can you please compare your application with my code, and can you please point out any differences in our codes?

    --

    Thanks & regards,
    Jagadish.

  • Hello Jagadish,

    There are not too many differences. The DCC configuration parameters are the same. Your dccInit also configures DCC2 and the seeds are configured after. My application does not configure DCC2. Your program stay in a loop waiting for the result. My application starts the test, does a lot of other things (including treating other perifherals), which take more time than the test itself, and then returns to check the test result.

    I will move the test code to my application and run it on our board, and post the result on this thread. The hardware team is also involved to check the EXTCLKIN1 input.

    Thanks and regards,

    Marcio.

  • Hi Marcio,

    I will move the test code to my application and run it on our board, and post the result on this thread. The hardware team is also involved to check the EXTCLKIN1 input.

    I would say this is a good idea.

    --

    Thanks & regards,
    Jagadish.