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/MSP430F5132: How to read P1.5 pins every 1 ms?

Part Number: MSP430F5132
Other Parts Discussed in Thread: TIDA-00121

Tool/software: Code Composer Studio

Hello everyone

I have a question about reading the P1.5 pin input, I want it to read P1.5 pins every 1 ms, I want to know if the P1.5 pin logic is high or low.

The code I wrote it reads the input pin P1.5 only the first time and never again.

I am using software development from TIDA-00121.

Set up I/O

void init_IO (void)
    {
        P1SEL |= BIT7;                                          //CONFIGURE TD0.1 , PW_H
        P1DIR |= BIT7;                                          //OUTPUT HIGH SIDE MOSFET
        P2SEL |= BIT0 + BIT2;                                   //CONFIGURE TD0.2 , TD1.1 FOR PW_L , PW_B
        P2DIR |= BIT0 + BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7 ;      //OUTPUT LOW SIDE MOSFET , BOOST STAGE MOSFET


        P1DIR &= ~BIT5 ;   //explicitly making P1.3 as Input - even though by default its Input
        P1REN = BIT5;      //Enable Pullup/down
        P1OUT = BIT5;       //Select Pullup

        DIS_ACDC_ForLoad;
        DIS_Supply15V;
        DIS_Battery_ForLoad;

        P3DIR |= BIT0 + BIT1 + BIT2 + BIT3;
//      P3DIR &= ~BIT0 + ~BIT1;
        PJDIR |= BIT6;                                  //CONFIGURE OUTPUT PORTS FOR ENABLE SIGNALS

        PMAPPWD = 0x02D52;      // Enable Write-access to modify port mapping registers
        PMAPCTL = PMAPRECFG;    // Allow reconfiguration during runtime
        P1MAP0|= PM_ANALOG;    // Modify all PxMAPy registers
        P1MAP1|= PM_ANALOG;    // Modify all PxMAPy registers
        P1MAP2|= PM_ANALOG;    // Modify all PxMAPy registers
        P1MAP3|= PM_ANALOG;    // Modify all PxMAPy registers
        P1MAP4|= PM_ANALOG;    // Modify all PxMAPy registers
        P1MAP5|= PM_ANALOG;    // Modify all PxMAPy registers
        PMAPPWD = 0;            // Disable Write-Access to modify port mapping registers by writing incorrect key
        P1SEL |= BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5;   // setting the port mapping register PxMAPy to PM_ANALOG together with PxSEL.y=1 when applying analog signals

        //PANEL_DISABLE;
        //LOAD_DISABLE;
        _BIS_SR(GIE); // enable global interrupts
    }

Set up read P1.5 pin every 1 ms :

__interrupt void TIMER0_A0_ISR(void)
{

		ms++;
			if(ms == 1000)
			{
				sec++;
				ms = 0;
				if(P1IN&BIT5)
				{
				    AC_ON = 1;
				    Present_State = START_LOAD_MANAGEMENT_STATE;
				 }

			}

			TA0CCTL0 &= ~CCIFG;
			TA0CTL &= ~TAIFG;
}

  • How do you tell that you are reading P1.5 exactly once?

    ----------

    How is timer TA0 configured? Based on the variable names, it appears you're only reading P1.5 once per second (1000 ms). Is that your intention?

    --------- 

    >        P1MAP5|= PM_ANALOG;    // Modify all PxMAPy registers
    >        P1SEL |= BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5;   // setting the port mapping 

    I'm not sure I understand why you're setting P1.5 to Analog mode. Among other things, it turns off the REN resistor you switched on above. If what's at the other end of the (P1.5) wire is relying on the REN pullup it won't work. What is your goal here?

    --------- 

    What do you have connected to P1.5? As I read the TIDA-00121 schematics, there's nothing connected to P1.5.

  • Can you enter if(ms == 1000)

    for more than 2 times?

**Attention** This is a public forum