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/MSP430F6736: Addressing and assigning values

Part Number: MSP430F6736

Tool/software: Code Composer Studio

Hi team,

I want to assign the values that an input port receives to a variable.

For example, I want to assign the value that port 1 pin 1 receives, to a variable a.

How do I achieve this?

Thanks,

Keval

  • Hi Keval,

    Not sure if you talk about this:

    a = P1IN;

    This assigns the Port1 input register values to variable a.

    Best regards

    Lukas

  • Hi Keval,

    in general you create a variable and you assign the value of a register or other variable with the "=" operator. Please see the code snippet below.

    unsigned int myVariable = 0;
    
    
    myVariable = P1IN;        // store values of P1.0 to P1.7 into myVariable
    
    myVariable = P1IN & 0x01; // only store value of P1.0 into myVariable

    Please also check the following application notes on general coding techniques and search the forum for such questions.

    Software Coding Techniques for MSP430 MCUs

    Best regards,

    Andre

  • Hi Andre,

    I am using the following code for test:

    #include <msp430.h>
    #include <stdio.h>

    /**
     * main.c
     */
    int main(void)
    {
     WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
     P4DIR |= BIT0 | BIT1;
     P1DIR &= ~BIT2;
     unsigned int data;
     

    while(1)
    {

        P4OUT &= ~BIT0;
        P4OUT &= ~BIT1;
        data = P1OUT & 0x04;            //reading the data coming at pin P1.2
        printf("ADC data=%d",data);

    }
    }

    I have set breakpoint at the printf command line.

    I want to read the data coming to P1.2 and print it on the screen.

    But when I run the code and set the breakpoint, it is not printing the value. I have set the printf support to full and the stack size to 320 too.

    Is there anything wrong with the code?

    what is the issue? Could you help me out?

    Thanks,

    Keval

  • Keval Desai said:
    I have set the printf support to full and the stack size to 320 too.

    For printf to work also requires sufficient heap space - see Heap_Size on the Tips for using printf Wiki page.

  • Hi Andre,

    I have four digital signals that I have connected to port 5 pins 4,5,6,7.
    I want to increment the four signals (when combined) in such a manner that I get 0000,0001.0010,0011,....... 1111 as the sequence

    How do I achieve this?

    Thank you,
    Keval

**Attention** This is a public forum