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: Explanation about MSP432P401 delay provider

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hello my fellows,
I have facing some dificultys to understand how to provide a delay in MSP432P401R, so, I run the MSP432 clock system at 24MHz, after this I configure my SMCLK to run at 12MHz, when I calculate the delay wich clock I should use? the 24MHz or the 12MHz clock? How can I create a delay, can give me a example.

  • __delay_cycles generates a (CPU) spin-loop, so it implicitly uses MCLK.

    >#define HZ  24000000UL  // 24MHz

    >__delay_cycles(HZ/4);   // Spin for one-fourth of a second

  • Hello Bruce,

    Can I preforme a delay in the following way:

    void init_SysTick(void){
        SysTick->CTRL = 0;              /**/ Disable SysTick durring step
        SysTick->LOAD = 0xFFFFFFFF;     /**/ Max reload value
        SysTick->VAL = 0;               /**/ Anywrite to current clears it
        SysTick->CTRL = 0x00000005;     /**/ Enable SysTick, 24MHz, no interuptions
    }
    
    /*DELAY MICROSECONDS*/
    void delay_us(unsigned microseconds){
        SysTick->LOAD = (microsec * 24 - 1);
        SysTick->VAL = 0;
        while ((SysTick->CTRL & 0x00010000) == 0);
    }

    the "SysTick->CTRL = 0x00000005;"  it gives me a big doubt because it is not clear how it works

  • It seems that it should work. The meanings of the CTRL bits are given in TRM (SLAU356H) Table 2-54.

    It's not clear to me what you gain by doing it this way. You're still doing a spin loop based on MCLK, but it's cost you the use of SysTick.

**Attention** This is a public forum