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/MSP432P401R: The problem of measuring MSP432 machine cycles using CCS debug breakpoint count

Part Number: MSP432P401R

Tool/software: Code Composer Studio

hi all:

I need me to get the exact time of the program.So the method of using COUNT clock cycle in CCS DEBUG . I use the __delay_cycles () precise delay program for 1000 clock cycles.

Then read the value of count to see if it matches.The breakpoint of the program and the settings of the CCS debug breakpoint count are shown in the following picture.

After the program is run, the clock cycle is not 1000, but 2987, between the two measuring breakpoints of the program.As shown in the following picture

This is my doubt, I accurately delay 1000 clock cycles, why the CCS breakpoint count calculates the clock cycle is 2987?

  • Alex824,

    Can you try the following code?

    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    int main(void)
    {
        /* Stop Watchdog  */
        MAP_WDT_A_holdTimer();
    
        int mclk;
    
        while(1)
        {
            __delay_cycles(1000);
            mclk = CS_getMCLK();
        }
    }
    

    I set a breakpoint at __delay_cycles(1000); and a breakpoint at mclk = CS_getMCLK(); made a count event, set reset count on run. Ran to __delay_cycles(1000); ran it again, and received the following count.

    If this does work, let me know.

  • Thank you very much for your reply.

    1. I've tried three programs, and the first program is exactly the same as yours. The result is the same as you, the delay of 1000 clock cycles, the count is also 999.

    2. In the second program, I used DCO and raised MCLK to 48M. After 1000 clock cycles, the count is 1996. program and the results are as follows.

     

     /* DriverLib Includes */
    
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    int main(void)
    {
        int mclk;
    
         /* Stop Watchdog */
         MAP_WDT_A_holdTimer();
         MAP_Interrupt_disableMaster();
         //![Simple FPU Config]
         // Enabling FPU for DCO Frequency calculation
         MAP_FPU_enableModule();
    
         MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
         MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
         MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);
    
         // Setting the DCO Frequency to a standard 48MHz
         // Initializes Clock System
         MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
    
         MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
    
    
        while(1)
        {
            __delay_cycles(1000);
            mclk = CS_getMCLK();
        }
    }
    

    3. In the third program, I added the SMCLK, and the count after 1000 clock cycles is the 2987. program and the results are as follows

    /* DriverLib Includes */
    
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    int main(void)
    {
        int mclk;
    
         /* Stop Watchdog */
         MAP_WDT_A_holdTimer();
         MAP_Interrupt_disableMaster();
         //![Simple FPU Config]
         // Enabling FPU for DCO Frequency calculation
         MAP_FPU_enableModule();
    
         MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
         MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
         MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);
    
         // Setting the DCO Frequency to a standard 48MHz
         // Initializes Clock System
         MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
    
         MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
         MAP_CS_initClockSignal(CS_SMCLK,  CS_DCOCLK_SELECT,  CS_CLOCK_DIVIDER_2);
    
        while(1)
        {
            __delay_cycles(1000);
            mclk = CS_getMCLK();
        }
    }


  • Alex824,

    I can confirm that I see this behavior as well. I'm going to open an investigation into this to see what we can do about it. In the meantime, as I've been working with it, in a number of conditions, it seems to be accurate up to 24MHz clock operation. My suggestion would be to use it up to 24MHz or set up a timer that is sourced by MCLK to count clock cycles, starting the counter when you want and stopping it when you want while accounting for overflow.
  • hi Evan:
    Thank you very much for verifying my experiment,If you find the reason or solution later, please let me know. I will appreciate it very much.
  • Hi Evan:
    I found the reason for the deviation. The reason is that I set the FLASH waiting period of 2

    MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
    MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);

    I changed the FLASH waiting period to 1, and then the machine cycle was calculated with COUNT,The deviation has been reduced a lot.
    __delay_cycles(1000); -->count = 1333

    MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
    MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);

**Attention** This is a public forum