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.

MSP430FR4133: some issues about msp430 to receiveinfrared sensor digital output

Part Number: MSP430FR4133

I got some issues about msp430 code, I connected infrared sensor with p1.0, so I just identify whether p1.0 is high or low level, then let p1.7 generate different duty cycle PWM i.e. 7.5% at high level and 13% at low level.

but the result is that P1.7 just produces 7.5% PWM even if the sensor produces 0 and 1 output.

 

Here is my code,

 

#include <msp430.h>

 

void main(void)

{

    WDTCTL = WDTPW + WDTHOLD;   // Stop watchdog timer

 

    // Configure P1.0 as input mode with pull-down resistor enabled

    P1DIR &= ~BIT0;   // P1.0 input mode

    P1REN |= BIT0;    // P1.0 pull-up/down resistor enabled

    P1OUT &= ~BIT0;   // P1.0 pull-down resistor enabled

 

    // Configure P1.7 as output mode

    P1DIR |= BIT7;    // P1.7 output mode

    P1SEL |= BIT7;

 

    // Setup Timer_A0

    TA0CCR0 = 20000;    // Set Timer_A0 upper limit value

    TA0CTL = TASSEL__SMCLK + MC__UP + TACLR;  // Select SMCLK as clock source, UP mode, clear Timer_A0 counter

    TA0CCTL1 = OUTMOD_7;  // Set output mode 7 for PWM

 

    while(1)

    {

        if(P1IN & BIT0) // P1.0 high input state

        {

            TA0CCR1 = 2600; // 13% duty cycle

        }

        else // P1.0 low input state

        {

            TA0CCR1 = 1600; // 8% duty cycle

        }

    }

Thanks

  • 1) Supposing your sensor is a TSOP38-style demodulator, I suggest you not set the REN pulldown. Many/most of these deliver high via an internal pullup, and your REN pulldown (~20k usually) is fighting it, and might be winning. Also, idle is high so if anything you want a REN pullup.

    2) It's generally not useful to set the duty cycle more often than once per PWM period. IR protocols routinely generate pulses in the 1-2ms range, so you will see many transitions within your 20ms period; maybe your PWM period should be around 1ms or so.

    3) If you're using the Launchpad, P1.0 is connected to LED1 (JP1) and the backchannel UART (J101/TXD), either of which could get in the way. Longer term, you probably don't want P1.0, but instead a pin capable of timer capture, e.g. P8.3 is TA1.CCI2A, so maybe now is a good time for that.

  • Hi, thanks very much for your reply, I just confused what should I do if I decline the internal pull down resistor.

    What’s more, when I attach to p1.0, the ir sensor can control the LED1 i.e. something block off the light, it turns off, nothing it turns on. That means the output of ir sensor can be received by msp430.

    I just want the p1.0 can identify when it is hight level, p1.7 can generate 8% cycle duty PWM and when it is low, p1.7 can generate 13% PWM

  • What sensor are you using?

    Also, for FR-series devices you need to add:

    >  PM5CTL0 &= ~LOCKLPM5;   // Enable GPIO settings

  • IR sensor

    This is the IR sensor

    Now, the question is that the p1.7just generate one PWM, if I set pull-up resistor, the p1.0 is always high level, P1.7 generate 7.5%PWM, even if I do not use the pull-up and pull-down resistors, the p1.7 just produce 13% PWM

  • It turned out I had an analogous device in a drawer. I tried your code (+LOCKLPM5 fix), and with JP1 removed I get consistent results. With JP1 installed, when OUT is high, it reads about 1.8V  (indeterminate logic level), presumably pulled-down by LED1. The pullup/downs didn't seem to make a difference, but I suspect you don't want them in any case.

    Did you try your experiment with JP1 removed?

  • Yeah, problem has been solved after removing JP1

    Thank you very much

**Attention** This is a public forum