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/MSP432P401R: MSP432P401R programming in Code Composer Studio

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hi,

 I am currently working with MSP432401R ,I would like to know how to give an input in code composer studio. Earlier I have been using Energia to code wherein I can declare my pins as  INPUTs or OUTPUTs as per my requirement but its quite confusing to declare inputs and outputs in CCS. It would be helpful if you could clarify this and if possible with an example.

Thanks.

  • Just use the MSP432 GPIO examples. Using DriverLib:

    int main(void)
    {
    volatile uint32_t ii;
    /* Halting the Watchdog */
    MAP_WDT_A_holdTimer();
    /* Configuring P1.0 as output */
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    while (1)
    {
    /* Delay Loop */
    for(ii=0;ii<5000;ii++)
    {
    }
    MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
    }
    }

  • I am new to CCS. Having used Energia so far, I find CCS difficult to use as I am not aware of the many functions and their use in a program. For example, I understand the function MAP_GPIO_setAsOutputPin() but what function should I use if want to receive an input and compare the value? My aim is to develop a program that receives the input from a radar and compares the input value to a fixed value and make the LED glow. It would be very useful to me if you could give a documentation of the most commonly used functions and their application.

    Thanks in advance.
  • Peruse the example code. Resource explorer also has a documentation section which has the driverlib reference PDF.

    In CCS, select View->Resource Explorer

    When that pops up, click the triangle for "Software"
    Click the triangle for Simplelink MSP432P4 SDK
    Click the triangle for Documents
    Click the triangle for DriverLib

    Download the PDF
  • Thank you Keith. I will look into the documentation. Meanwhile, I wrote a program to turn on the LED when the button is pressed and the LED should turn off when the button is released.

    #include <msp432p401r.h>


    /**
    * main.c
    */
    void button1_init(void){
    P1->SEL0 &= ~0x02;
    P1->SEL1 &= ~0x02;
    P1->DIR &= ~0x02;
    }


    void LED_ouit(void){
    P1->SEL0 &= ~0x01;
    P1->SEL1 &= ~0x01;
    P1->DIR |= 0x01;
    }

    void LED_exe(uint8_t new){
    /*uint8_t old;
    old = P1->OUT;
    old = old&(~0x01);
    new = new|old;*/
    P1->OUT =new;
    }


    uint8_t button_exe(void)
    {
    uint8_t button;
    button = P1->IN;
    button = button&0x02;
    return button;
    }

    void main(void)
    {
    uint8_t data;
    int i;
    WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // stop watchdog timer
    button1_init();
    LED_ouit();


    while(1){

    for(i=1;i<500;i++){

    }

    data = button_exe();

    if(data==2){
    LED_exe(1);
    }
    else{
    LED_exe(0);
    }
    }
    }

    But unfortunately ,When I executed the program, The LED is turned ON and doesnot follow the input button press. could you please look into the code and kindly let me know what mistake i would have done probably.

    Thanks.

  • Someone else will have to chime in. I use driverlib since it is much more readable.
  • If you are using the launchpad then the gpio input needs to have the internal pullup selected.

    Here is documentation about the driverlib gpio APIs:
    dev.ti.com/.../group__gpio__api.html

    Here is an example:
    dev.ti.com/.../

    Regards,
    Chris
  • I am not able to include the driver library in my code. What should I do ?
  • You have a couple of choices. One, you can stay with the register level implementation and follow this example : dev.ti.com/.../

    Alternatively, you can import the project above, but this assumes that you have installed the SDK. If you have not installed the SDK, then you can find it here:
    www.ti.com/.../SIMPLELINK-MSP432-SDK

    Regards,
    Chris