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.

TM4C129ENCPDT: Using EPI with TI RTOS - Configuring EPI and its associated GPIO for General Purpose Mode

Part Number: TM4C129ENCPDT

Hello,

My objective is to establish a parallel communication bus between this MCU and an FPGA (Lattice Mach X02, or something similar).  My design is using the EPI interface with the following configurations:

  • General Purpose Mode
  • 8-bit data
  • 4-bit address
  • Clock is gated
  • RD and WR bits are used to specify data direction

I have based my project off of the tcpEcho example included in the TI RTOS projects. Furthermore, I have created a initialization function called "InitEpi()", which setups the EPI to function as above. Note - I know that this function works, since I have tested it with a non-RTOS project:

int32_t InitEpi(void)
{
    int32_t returnVal = -1;
    
    //
    // Sets the usage mode of the EPI module.
    // The general purpose 8-bit data mode will be used.
    //
    EPIModeSet(EPI0_BASE, EPI_MODE_GENERAL);
    //EPI CLK is 1/2 of SysClk
    EPIDividerSet(EPI0_BASE, 0x1);

    EPIConfigGPModeSet
    (
            EPI0_BASE,
            (EPI_GPMODE_CLKPIN | /*EPI_GPMODE_CLKGATE |*/ EPI_GPMODE_ASIZE_20 | EPI_GPMODE_DSIZE_8),
            0,
            0
            );

    //NM I am not sure if this is correct for the address map, but saw this configuration used in an example
    EPIAddressMapSet(EPI0_BASE, EPI_ADDR_PER_SIZE_256B | EPI_ADDR_PER_BASE_A);
                                

    returnVal = 1;
        
    
    return returnVal;
}

Here is the problem. When I call InitEpi() from main, I place it right after the Board_initEMAC(); function, which was from the tcpEcho example:

int main(void)
{
    /* Call board init functions */
    Board_initGeneral();
    Board_initGPIO();
    Board_initEMAC();

    InitEpi();

    System_printf("Starting the TCP Echo example\nSystem provider is set to "
                  "SysMin. Halt the target to view any SysMin contents in"
                  " ROV.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();

    /* Start BIOS */
    BIOS_start();

    return (0);
}

This causes the MCU to crash.

Now, I have been doing some reading on GPIO initialization using the TI RTOS, and I know that there is a data structure (GPIO_PinConfig) that handles this. But, I do not know if I need to initialize the EPI using this structure, nor do I know how to do this. Also, can this all be done using the XGCONFIG tool? Lots of sources say that initializing various peripherals with TI RTOS is "easy", but I am struggling.

Thank you!

  • Hi Noah,

    When I call InitEpi() from main, I place it right after the Board_initEMAC(); function, which was from the tcpEcho example:

    This causes the MCU to crash.

    Is the crash happened inside initEpi()  or after initEpi() is executed.  Do you know what line of code caused the crash? From what I read on your initEpi() I don't really see you enable the EPI module unless you did somewhere else in your code. Where is the below line in your code? Without enabling the module, any access to the EPI module will cause a bus fault. 

    SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);

    Now, I have been doing some reading on GPIO initialization using the TI RTOS, and I know that there is a data structure (GPIO_PinConfig) that handles this.
    Also, can this all be done using the XGCONFIG tool?

    the .cfg for Tiva processor does not support EPI. Therefore, you cannot use .cfg to configure the EPI module. 

  • Charles,

    Thank you!  Not only did I forget that my example project (the non-RTOS project) enabled the EPI peripheral, it also configured the GPIO for EPI functionality in another private function. My function InitEpi is now working with the RTOS. Here is the full module in case someone else finds this useful:

    ///////////////////////////////////////////////////////////////////////////////

    // Includes
    #include "app/inc/epiDriver.h"
    #include "inc/hw_memmap.h"

    #include <driverlib/pin_map.h>
    #include <driverlib/gpio.h>
    #include <driverlib/sysctl.h>
    // Constants

    // Modular Variables

    // ============================================================================
    // Private Functions
    // ============================================================================
    //=============================================================================
    /**
    @return
    - int32_t
        * Positive value means that execution was valid
        * Negative value means that execution was invalid

    Configures the EPI GPIO.

    */
    static int32_t InitEpiGpio(void)
    {
        int32_t returnVal = -1;

        //
        // Configure the GPIO Pin Mux for PK4
        // for EPI0S32
        //
        GPIOPinConfigure(GPIO_PK4_EPI0S32);
        GPIOPinTypeEPI(GPIO_PORTK_BASE, GPIO_PIN_4);

        //
        // Configure the GPIO Pin Mux for PL4
        // for EPI0S26
        //
        GPIOPinConfigure(GPIO_PL4_EPI0S26);
        GPIOPinTypeEPI(GPIO_PORTL_BASE, GPIO_PIN_4);

        //
        // Configure the GPIO Pin Mux for PK6
        // for EPI0S25
        //
        GPIOPinConfigure(GPIO_PK6_EPI0S25);
        GPIOPinTypeEPI(GPIO_PORTK_BASE, GPIO_PIN_6);

        //
        // Configure the GPIO Pin Mux for PL0
        // for EPI0S16
        //
        GPIOPinConfigure(GPIO_PL0_EPI0S16);
        GPIOPinTypeEPI(GPIO_PORTL_BASE, GPIO_PIN_0);

        //
        // Configure the GPIO Pin Mux for PG0
        // for EPI0S11
        //
        GPIOPinConfigure(GPIO_PG0_EPI0S11);
        GPIOPinTypeEPI(GPIO_PORTG_BASE, GPIO_PIN_0);

        //
        // Configure the GPIO Pin Mux for PA6
        // for EPI0S8
        //
        GPIOPinConfigure(GPIO_PA6_EPI0S8);
        GPIOPinTypeEPI(GPIO_PORTA_BASE, GPIO_PIN_6);

        //
        // Configure the GPIO Pin Mux for PH1
        // for EPI0S1
        //
        GPIOPinConfigure(GPIO_PH1_EPI0S1);
        GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_1);

        //
        // Configure the GPIO Pin Mux for PP3
        // for EPI0S30
        //
        GPIOPinConfigure(GPIO_PP3_EPI0S30);
        GPIOPinTypeEPI(GPIO_PORTP_BASE, GPIO_PIN_3);

        //
        // Configure the GPIO Pin Mux for PB2
        // for EPI0S27
        //
        GPIOPinConfigure(GPIO_PB2_EPI0S27);
        GPIOPinTypeEPI(GPIO_PORTB_BASE, GPIO_PIN_2);

        //
        // Configure the GPIO Pin Mux for PN4
        // for EPI0S34
        //
        GPIOPinConfigure(GPIO_PN4_EPI0S34);
        GPIOPinTypeEPI(GPIO_PORTN_BASE, GPIO_PIN_4);

        //
        // Configure the GPIO Pin Mux for PQ1
        // for EPI0S21
        //
        GPIOPinConfigure(GPIO_PQ1_EPI0S21);
        GPIOPinTypeEPI(GPIO_PORTQ_BASE, GPIO_PIN_1);

        //
        // Configure the GPIO Pin Mux for PL3
        // for EPI0S19
        //
        GPIOPinConfigure(GPIO_PL3_EPI0S19);
        GPIOPinTypeEPI(GPIO_PORTL_BASE, GPIO_PIN_3);

        //
        // Configure the GPIO Pin Mux for PM0
        // for EPI0S15
        //
        GPIOPinConfigure(GPIO_PM0_EPI0S15);
        GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_0);

        //
        // Configure the GPIO Pin Mux for PM2
        // for EPI0S13
        //
        GPIOPinConfigure(GPIO_PM2_EPI0S13);
        GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_2);

        //
        // Configure the GPIO Pin Mux for PB3
        // for EPI0S28
        //
        GPIOPinConfigure(GPIO_PB3_EPI0S28);
        GPIOPinTypeEPI(GPIO_PORTB_BASE, GPIO_PIN_3);

        //
        // Configure the GPIO Pin Mux for PQ3
        // for EPI0S23
        //
        GPIOPinConfigure(GPIO_PQ3_EPI0S23);
        GPIOPinTypeEPI(GPIO_PORTQ_BASE, GPIO_PIN_3);

        //
        // Configure the GPIO Pin Mux for PG1
        // for EPI0S10
        //
        GPIOPinConfigure(GPIO_PG1_EPI0S10);
        GPIOPinTypeEPI(GPIO_PORTG_BASE, GPIO_PIN_1);

        //
        // Configure the GPIO Pin Mux for PK5
        // for EPI0S31
        //
        GPIOPinConfigure(GPIO_PK5_EPI0S31);
        GPIOPinTypeEPI(GPIO_PORTK_BASE, GPIO_PIN_5);

        //
        // Configure the GPIO Pin Mux for PP2
        // for EPI0S29
        //
        GPIOPinConfigure(GPIO_PP2_EPI0S29);
        GPIOPinTypeEPI(GPIO_PORTP_BASE, GPIO_PIN_2);

        //
        // Configure the GPIO Pin Mux for PH3
        // for EPI0S3
        //
        GPIOPinConfigure(GPIO_PH3_EPI0S3);
        GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_3);

        //
        // Configure the GPIO Pin Mux for PC5
        // for EPI0S6
        //
        GPIOPinConfigure(GPIO_PC5_EPI0S6);
        GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_5);

        //
        // Configure the GPIO Pin Mux for PA7
        // for EPI0S9
        //
        GPIOPinConfigure(GPIO_PA7_EPI0S9);
        GPIOPinTypeEPI(GPIO_PORTA_BASE, GPIO_PIN_7);

        //
        // Configure the GPIO Pin Mux for PH0
        // for EPI0S0
        //
        GPIOPinConfigure(GPIO_PH0_EPI0S0);
        GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_0);

        //
        // Configure the GPIO Pin Mux for PC4
        // for EPI0S7
        //
        GPIOPinConfigure(GPIO_PC4_EPI0S7);
        GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_4);

        //
        // Configure the GPIO Pin Mux for PL1
        // for EPI0S17
        //
        GPIOPinConfigure(GPIO_PL1_EPI0S17);
        GPIOPinTypeEPI(GPIO_PORTL_BASE, GPIO_PIN_1);

        //
        // Configure the GPIO Pin Mux for PL5
        // for EPI0S33
        //
        GPIOPinConfigure(GPIO_PL5_EPI0S33);
        GPIOPinTypeEPI(GPIO_PORTL_BASE, GPIO_PIN_5);

        //
        // Configure the GPIO Pin Mux for PN5
        // for EPI0S35
        //
        GPIOPinConfigure(GPIO_PN5_EPI0S35);
        GPIOPinTypeEPI(GPIO_PORTN_BASE, GPIO_PIN_5);

        //
        // Configure the GPIO Pin Mux for PM1
        // for EPI0S14
        //
        GPIOPinConfigure(GPIO_PM1_EPI0S14);
        GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_1);

        //
        // Configure the GPIO Pin Mux for PK7
        // for EPI0S24
        //
        GPIOPinConfigure(GPIO_PK7_EPI0S24);
        GPIOPinTypeEPI(GPIO_PORTK_BASE, GPIO_PIN_7);

        //
        // Configure the GPIO Pin Mux for PC7
        // for EPI0S4
        //
        GPIOPinConfigure(GPIO_PC7_EPI0S4);
        GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_7);

        //
        // Configure the GPIO Pin Mux for PL2
        // for EPI0S18
        //
        GPIOPinConfigure(GPIO_PL2_EPI0S18);
        GPIOPinTypeEPI(GPIO_PORTL_BASE, GPIO_PIN_2);

        //
        // Configure the GPIO Pin Mux for PM3
        // for EPI0S12
        //
        GPIOPinConfigure(GPIO_PM3_EPI0S12);
        GPIOPinTypeEPI(GPIO_PORTM_BASE, GPIO_PIN_3);

        //
        // Configure the GPIO Pin Mux for PQ0
        // for EPI0S20
        //
        GPIOPinConfigure(GPIO_PQ0_EPI0S20);
        GPIOPinTypeEPI(GPIO_PORTQ_BASE, GPIO_PIN_0);

        //
        // Configure the GPIO Pin Mux for PQ2
        // for EPI0S22
        //
        GPIOPinConfigure(GPIO_PQ2_EPI0S22);
        GPIOPinTypeEPI(GPIO_PORTQ_BASE, GPIO_PIN_2);

        //
        // Configure the GPIO Pin Mux for PC6
        // for EPI0S5
        //
        GPIOPinConfigure(GPIO_PC6_EPI0S5);
        GPIOPinTypeEPI(GPIO_PORTC_BASE, GPIO_PIN_6);

        //
        // Configure the GPIO Pin Mux for PH2
        // for EPI0S2
        //
        GPIOPinConfigure(GPIO_PH2_EPI0S2);
        GPIOPinTypeEPI(GPIO_PORTH_BASE, GPIO_PIN_2);

        returnVal = 1;

        return returnVal;
    }
    // ============================================================================
    // Public Functions
    // ============================================================================
    //=============================================================================
    /**
    @return
    - int32_t
        * Positive value means that execution was valid
        * Negative value means that execution was invalid

    Initializes the external peripheral interface.

    */
    int32_t InitEpi(void)
    {
        int32_t returnVal = -1;
        
        InitEpiGpio();

         //
        // The EPI0 peripheral must be enabled for use.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);
        
        //
        // Sets the usage mode of the EPI module.
        // The general purpose 8-bit data mode will be used.
        //
        EPIModeSet(EPI0_BASE, EPI_MODE_GENERAL);
        //EPI CLK is 1/2 of SysClk
        EPIDividerSet(EPI0_BASE, 0x1);

        EPIConfigGPModeSet
        (
                EPI0_BASE,
                (EPI_GPMODE_CLKPIN | /*EPI_GPMODE_CLKGATE |*/ EPI_GPMODE_ASIZE_20 | EPI_GPMODE_DSIZE_8),
                0,
                0
                );

        //NM I am not sure if this is correct for the address map, but saw this configuration used in an example
        EPIAddressMapSet(EPI0_BASE, EPI_ADDR_PER_SIZE_256B | EPI_ADDR_PER_BASE_A);
                                    

        returnVal = 1;
            
        
        return returnVal;
    }