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.

MSP432E401Y: MSP432 gpio programming in code composer stduio

Part Number: MSP432E401Y
Other Parts Discussed in Thread: SYSCONFIG

Hi all, 

I'm curious to learn MSP432E4 programming, I have custom board, I want to use SPI, Uart, rs485 etc communications. But I'm really dont know how to start than I decided to read user manual for simple GPIO registers etc.Below is the LED glow code, can you review it and tell me whether my understanding is correct or not . I'm developing on Code composer studio.

code :
// set the direction as output
      GPIOM->DIR = 0x01;
//DEN register -digital enable register
      GPIOM->DEN = 0x01;
//GPIO data register
      GPIOM->DATA = 0x01;

My doubts are,
1. MSP432E401Y simple link example codes are available in  resource explorer or ti forum - can I reuse those code, I mean, can I change gpio pins according to my need ? because I have custom board developed.

  • "1. MSP432E401Y simple link example codes are available in  resource explorer or ti forum - can I reuse those code, I mean, can I change gpio pins according to my need ?"

    Of course you can. Why would you expect otherwise?

  • thanks Andy,
    I thought examples codes will work only with launch pads.

    Is my GPIO code correct ?

  • Is your code correct? I don't know, you posted only three lines without useful comments or explanations. Nobody can tell what port is connected to your LED, or how that LED is wired. There is also the small matter of enabling the GPIO peripheral, setting up the clock, all of it.

    I use the TivaWare code which abstracts the direct register access to human-understandable functions. 

    Examples only work with LaunchPads because the LaunchPads use specific pins and peripherals. If your design uses different pins and peripherals, the examples can be modified to use them. If your design uses the same mix of peripherals with the same pinouts, the examples should work. The examples are meant as a starting point and to demonstrate various features. When designing a product you will likely choose a different mix of peripherals and pinouts.

  • Thank you Andy for detailed answer.
     I rewrite the code and will post here

  • Hi Andy,
    I got a Tiva TM4C123Gxl launch pad

    I have tried uart echo example code working perfectly. So, using same code with modified uart port and others as shown in the below code. Now i have used PORTE1 and I have connected  PORTE1 pin to FTDI serial communication RX pin and lanuch pad gnd pin to FTDI gnd pin. And i have used in built function UARTwrite() to send data. And checked the baud rate as well -115200.

    But Im unable to receive data on the serial terminal (Tera Term), what could be wrong here?

    void
    ConfigureUART(void)
    {
    //
    // Enable the GPIO Peripheral used by the UART.
    //
    // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    //
    // Enable UART0
    //
    // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);

    //
    // Configure GPIO Pins for UART mode.
    //
    // MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
    // MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
    // MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    // MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
    MAP_GPIOPinConfigure(GPIO_PE1_U7TX);
    MAP_GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_1);

    //
    // Use the internal 16MHz oscillator as the UART clock source.
    //
    // UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    UARTClockSourceSet(UART7_BASE, UART_CLOCK_PIOSC);

    //
    // Initialize the UART for console I/O.
    //
    UARTStdioConfig(0, 115200, 16000000);

     UARTwrite("d\n\r", 1); // INBUILT FUNCTION 

    }


    //*****************************************************************************
    //
    // Print "Hello World!" to the UART on the evaluation board.
    //
    //*****************************************************************************
    int
    main(void)
    {
    //volatile uint32_t ui32Loop;

    //
    // Enable lazy stacking for interrupt handlers. This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    MAP_FPULazyStackingEnable();

    //
    // Set the clocking to run directly from the crystal.
    //
    MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
    SYSCTL_OSC_MAIN);

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable the GPIO pins for the LED (PF2 & PF3).
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

    //
    // Initialize the UART.
    //
    ConfigureUART();

    //UARTCharPutNonBlocking(UART7_BASE,"byte");

    //
    // We are finished. Hang around doing nothing.
    //
    while(1)
    {
    //
    // Turn on the BLUE LED.
    //
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);

    //
    // Delay for a bit.
    //
    SysCtlDelay(SysCtlClockGet() / 10 / 3);

    //
    // Turn off the BLUE LED.
    //
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);

    //
    // Delay for a bit.
    //
    SysCtlDelay(SysCtlClockGet() / 10 / 3);
    }
    }

  • Is the FTDI chip configured correctly, however that has to be done? 

  • UARTStdioConfig(0, 115200, 16000000);

    The first argument in my copy of UARTStdioConfig is the UART number. You appear to be trying to use UART7, so that should be 7 rather than 0. My copy of that function (g_ui32UARTPeriph[]) only recognizes UART0-2, so you should probably check that table.

    --------------

    Are you using an MSP432E401Y or a TM4C123G? On the MSP432E401Y UART7 is on PC4-5, not PE1-?. [Ref data sheet (SLASEN5) Table 4-4].

  • I'm using TM4 ,so pin number is correct PE1

    And if I choose any uart (0-2) Should work rite? Which table referring here for uart? 

  • Check the arraty g_ui32UARTPeriph[], up at the beginning of UARTstdio.c, and see how many entries it has. My copy, from the MSP432E401Y enet_with_lwip example, ,has only 3 entries.

  • Thank you so much Bruce, finally got it work now - I have changed the entries 

  • Is there any tool for generating peripherals initialization from TI ? like for stm32 controllers STM32CUBEMX is the tool which generates the peripherals initialization.

  • Hi Srinivas,

    You can refer to sysconfig tool:https://www.ti.com/tool/SYSCONFIG?keyMatch=SYSCONFIG%20TOOL&tisearch=search-everything

    It is integrated in CCS already.

    Eason

  • Thank you so much Eason, I have downloaded tool from above link. Do we need to save the each file which we selected or Is there any way import directly ?

    But I didn't find in the CCS tool  - where to find it ?

  • For the use of sysconfig, you can refer to this:software-dl.ti.com/.../Users_Guide.html

    I think you can directly import a TI-Driver example code. Then you will see it in you CCS.dev.ti.com/.../node But as I check, the example code are all RTOS.