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.

Port initialisation on RF430FRL152H

Other Parts Discussed in Thread: RF430FRL152HEVM, TRF7970A, MSP-FET, RF430FRL152H

Hi there

I am using the RF430FRL152HEVM. I want to setup P1.2 as an input, and have written the following function:

void initInterrupt()
{
//initialising P1.2 for PERIPHERAL_RDY interrupt on rising edge


P1DIR &= ~BIT2; //P1.2 as input
P1SEL0 &= ~BIT2;
P1SEL1 = 0x00;
P1REN &= ~BIT2; //enable pullup/pulldown resistor
P1OUT &= ~BIT2; //enable pulldown resistor

P1IE |= BIT2; //enable interrupt
P1IES &= ~BIT2; //rising edge, set P1IFG (flag) high
P1IFG &= ~BIT2; //clear interrupt flag
//when P1IFG is set high, enter ISR (check #pragma vector on port1), at the end of the ISR, clear P1IFG flag
return;
}

When I execute the function (in the main()), and measure P1.2 the line is floating at a logical 1 (~1.5 V). As I understand, it should be floating at a 0 when the pin is set to an input. I have successfully driven an LED through P1.4 on the EVM, and NFC communication with the TRF7970A is working fine. Advice?

  • Your code looks fine expect for one line which may not make a difference for your problem:

    Michael Maas said:
    P1REN &= ~BIT2; //enable pullup/pulldown resistor

    The above line disables pull functionality for the pin, you need to set it high.

    I tested your code and my measurements show that the pin is at a low-level.  I put a __no_operation(); statement at the end of your function and tested the pin level and it was correct.

    Perhaps you are checking after running other code which may change the setting.

    I would recommend checking the state of the pin at the MCU instead of after the level translator (on the headers) since in theory it could be at either state.

    Here is the code that I checked with slight modifications (to enable JTAG):

    void initInterrupt()
    {

        //initialising P1.2 for PERIPHERAL_RDY interrupt on rising edge

        P1DIR &= ~BIT2; //P1.2 as input

    //device init called in the NFC only project sets P1SEL0 and P1SEL1 both to 0xF0 to keep JTAG

        //P1SEL0 &= ~BIT2;
        //P1SEL1 = 0x00;
        P1REN &= ~BIT2; //enable pullup/pulldown resistor
        P1OUT &= ~BIT2; //enable pulldown resistor
        P1IE |= BIT2; //enable interrupt
        P1IES &= ~BIT2; //rising edge, set P1IFG (flag) high
        P1IFG &= ~BIT2; //clear interrupt flag
        //when P1IFG is set high, enter ISR (check #pragma vector on port1), at the end of the ISR, clear P1IFG flag

    //breakpoint below
        __no_operation(); //breakpointed here and checked the state of the pin P1.2

    }

  • Hi Alexander

    Thanks for the help.

    I was measuring the pin out at the MCU, but now i disconnected the MSP-FET and the USB, and switched S6 to battery (it shows a "0"). When I connect the USB, and switch S6 to Battery, the pin also shows a "0". What was your setup on the EVM (USB, FET, S6 connection)? P1.2 seems to be high from the start (USB connected, S6 on Supply), maybe I am misunderstanding the power circuitry on the EVM?

    I checked my other code, I only have an I2C initialisation function, which I have pasted below, which is called before initialising P1.2. 

    void initI2C()

    { //ROM sets P1OUT = 0x0F, this then consumes some current
    P1OUT = 0x00; //needed to reduce power consumption on RF430FRL152H EVM, since P1.3 is connected to a 2.2K Ohm resistor on the EVM to ground
    P1DIR &= ~MASTER_SLAVE_SELECT; // check if digital sensor mode is selected
    if (P1IN & MASTER_SLAVE_SELECT)
    {
    //P1DIR &= ~MASTER_SLAVE_SELECT; //host controller mode selected, exit
    return;
    }
    /* For custom digital sensor initialization, keep the previous code as is and change the following as needed.*/
    PORT_I2C_SEL0 |= SCL + SDA; // Configure P1.0 and P1.1 pins for I2C mode
    PORT_I2C_SEL1 &= ~(SCL + SDA);
    // configure eUSCI for I2C
    UCB0CTL1 |= UCSWRST; // Software reset enabled
    UCB0CTLW0 |= UCMODE_3 + UCMST + UCSYNC + UCTR; // I2C mode, Master mode, sync, transmitter
    UCB0CTLW0 |= UCSSEL_2; // select SMCLK at 2MHz
    UCB0BRW = 10; // 2Mhz / 10 = 200kHz
    UCB0I2CSA = 0x0064; // slave address of SHT21, initially
    UCB0CTL1 &= ~UCSWRST; // exit reset mode

    return;
    }

  • I am not sure which example project that you are using.  In the previous test that I tried, I was using the "NFC only" project.  However if you are using the SensorHub example project, P1.0-P1.3 are all driven high before the "DigitalSensorInit" function is called.  If your "initInterrupt" is called before this or is never called at all, I can see this problem happening.

    I would recommend that you debug your project and using breakpoints make sure that your order of execution is as expected.

  • Hi Alexander

    I am also using the NFC only project. I changed the pin from p1.2 to p1.3, and now it is working.

    I reworked U6 (level translator), maybe it influenced P1.2 in some way....still not sure, but thanks for the help!