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/MSP-EXP430F5529: Reading digital input signal from function generator

Part Number: MSP-EXP430F5529

Tool/software: Code Composer Studio

Hello everyone,

i am trying to define input pin like p1.3 and take it's value from function generator (pulse wave)

i just wanna toggle  led in my board like led1 (p1.0) when i read this input pin to check if my signal stored in this pin

this is my code but it is not work correctly 

#include <msp430.h>

void main(void) {
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P1DIR |= 0x01; // configure led1 P1.0 as output P1OUT &= ~BIT0; volatile unsigned int i; // volatile to prevent optimization P1DIR &= ~BIT3; //configure P1.3 as input while(1) { if (P1IN&BIT3==0) { for (i=0; i<2000 ; i++); P1OUT |=BIT0;
} } }
  • Hello Beso,

    In the future, please post your code using the Syntax Highlighter icon below. Without it, the code is hard to read and there's probably a lower chance that our community members will look through it and provide recommendations. I went ahead and fixed your initial post above.

    Have you looked at our code examples in TI Resource Explorer? You'll find helpful code examples that you can download and modify to achieve what you're trying to do. I would not recommend polling as you're doing above, since you could miss the input signal transitions depending on the timing. If the input transitions very slowly, then polling may work. At a higher level, interrupts are preferred over polling since it's more efficient.

    If you'd like to use polling, then refer to the 'MSP430F55xx_P1_01.c' code example and just change the P1.4 code to P1.3.

    Regards,

    James

  • Dear James,

    Thank you so much

    my code works now