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.

MSP432P401R: MSP432P401R

Part Number: MSP432P401R


I have an MSP432p401r Launchpad and I am using Code Composer Studio 7.3.0. I am playing around with the TIMER_A0 and I'm using the SMCLK at 3MHz. I want to change the SMCLK and I read in the technical manual that I can change it but I need to write 0x695A to CSKEY register. The issue is CSKEY is not defined in the msp432p401r.h header file. The CS_KEY_VALUE is defined and other CS variables are defined but not the CSKEY. So when I try to compile my c code, I get an error saying CSKEY is undefined. I am just wondering were is the CSKEY definition.

I also created a pointer to the address location of CSKEY like this:

#define CSKEY   (*((volatile uint32_t *)0x40010400))

When I create my own CSKEY my compiler will compile just fine but when I go through the debugger to see if the CSKEY register was written to, the register is unchanged. 

Where can access the CSKEY pointer?

Why does my #define CSKEY not access the memory location in the clock system key register?

Thank you

  • Hi Xavier,

    Not really sure, let me give this a try and I'll get back to you.

    Best regards,

    David
  • Try "CS->KEY" (CMSIS style).
  • So when I use (CMSIS style) "CS->KEY" it compiles without any error which is great! Yay. But none of the CS address's registers get changed:

    CS->KEY = 0x695A;        // This is a password
    CS->CTL1 &= 0xAFFFFFFF;   // This should make the SMCLK at 750 kHz clock frequency
    CS->KEY = 0x1111;         // Anything but the password locks the settings

    After stepping through these three lines of code, in the debugger register view none of the register change and my LED light blinks at a 3MHz/64 frequency (basically the SMCLK clock was not changed.)

    Any ideas on why the CS->KEY or the CS->CTL1 registers were not changed?

  • According to SLAU356G Sec 5.3.1, CS->KEY "Always reads back A596h."
    According to Sec 5.3.3, the DIVS field is 0 at reset, so and-ing won't change anything. Try:

    CS->CTL1 |= CS_CTL1_DIVS_2; // DIVS=2: SMCLK/4 gives 0.75MHz

    Or, better (no assumptions):
    CS->CTL1 = (CS->CTL1 & ~CS_CTL1_DIVS_MASK) | CS_CTL1_DIVS_2; // DIVS=2: SMCLK/4 gives 0.75MHz
  • I see what I did wrong when I was writing to CS->CTL1 by and-ing. I was not modifying any bits When and-ing. I did mean to "or" initially. When I changed it to or-ing it worked, makes sense, thank you.

    And now I understand that after I assign CS->KEY the correct password I wont read back the password I will always read the reset number. 

    Thank you 

**Attention** This is a public forum