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.

PUR Pin Input

Other Parts Discussed in Thread: MSP430F5529, MSP-EXP430F5529LP

The LaunchPad with the MSP430F5529 has some push button switches. One of the switches goes to the PUR pin on the 5529. I have been unsuccessful to read from the pin. Could someone help with this?

I use this code to read from the pin and indicate it's value.

while(1) {
	if(USBCNF&PUR_IN)
		P4OUT |= BIT7;
	else
		P4OUT &= ~BIT7;
}

No matter the state of the switch, I have been getting P4.7 = 0. 

I tried to unlocking the configuration regs. And I tried, but unsuccessfully, setting the PUSEL.

I used this code to unlock and set PUSEL.

	USBKEYID = 0x9628;

	__delay_cycles(250u);						

	USBPHYCTL_L |= PUSEL;

  • That bit is powered by VUSB; do you have it?

    Is PUR_EN cleared?

  • Rodney Wong said:
    No matter the state of the switch, I have been getting P4.7 = 0.

    The MSP430F5529 datasheet SLAS590L suggests that PUSEL and PUREN both need to be one to set PUR as an input and enable a pull-up on PUR:

    Therefore, my initial attempt to read the state of the "BSL" S5 switch on the MSP-EXP430F5529LP was the following:

    #include <msp430.h> 
    
    /*
     * main.c
     */
    int main(void) {
        WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
    
        P4DIR |= BIT7;
        P1DIR |= BIT0;
    
        /* Enable PUR input and pull-up */
        USBKEYID = USBKEY;
        USBCNF |= PUR_EN;
        USBPHYCTL |= PUSEL;
        USBKEYID = 0;
    
        while (1)
        {
        	if (USBCNF & PUR_IN)
        	{
        		P4OUT |= BIT7;
        		P1OUT &= ~BIT0;
        	}
        	else
        	{
        		P4OUT &= ~BIT7;
        		P1OUT |= BIT0;
        	}
        }
    	
    	return 0;
    }
    

    However, with this code the PUR_IN bit always read as one, regardless of the state of the BSL S5 switch.

  • Given that the BSL S5 switch on the MSP-EXP430F5529LP does allow entry to the USB BSL I had a look at the MSP430 Custom BSL Package source code. The MSP430BSL_1_00_08_00/5xx_6xx_BSL_Source/MSP430F552x_USB/BSL430_Low_Level_Init.s43 source file shows the PSEIEN bit being set and then the PUR_IN input being read:

                  mov.w   #0x9628,   &USBKEYPID
                  bis.w   #PSEIEN,   &USBPHYCTL
                  bit.w   #PUR_IN,   &USBCNF
                  jnz     REQUEST_BSL               ; if PUR_IN set, request BSL
    

    Therefore, created this program which then successfully read the state of the BSL S5 switch connected to PUR:

    #include <msp430.h> 
    
    /*
     * main.c
     */
    int main(void) {
        WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
    
        P4DIR |= BIT7;
        P1DIR |= BIT0;
    
        /* Setting PSEIEN is required to read the state of PUR_IN.
         * This was taken from the USB BSL source code */
        USBKEYID = USBKEY;
        USBPHYCTL |= PSEIEN;
        USBKEYID = 0;
    
        while (1)
        {
        	if (USBCNF & PUR_IN)
        	{
        		P4OUT |= BIT7;
        		P1OUT &= ~BIT0;
        	}
        	else
        	{
        		P4OUT &= ~BIT7;
        		P1OUT |= BIT0;
        	}
        }
    	
    	return 0;
    }
    

  • Chester Gillon said:
    The MSP430BSL_1_00_08_00/5xx_6xx_BSL_Source/MSP430F552x_USB/BSL430_Low_Level_Init.s43 source file shows the PSEIEN bit being set and then the PUR_IN input being read

    PSEIEN is a legacy name, which doesn't appear in the MSP430F5529 datasheet or MSP430x5xx and MSP430x6xx Family User's Guide. The current name for this bit is PUIPE.

    The MSP430F5529 datasheet SLAS590L shows that PUIPE controls the input buffers for PU.0/DP and PU.1/DM, and PUSEL controls the input buffer for PURIN:

    Given that for code to read the state of PUR requires PUIPE to be set, rather than PUSEL, does this mean there is an error in the MSP430F5529 datasheet?

  • Thanks Chester. The code works. So the problem was the PSEIEN bit. Gezz, it was so hidden.

**Attention** This is a public forum