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.

F28335 GPIO setup



hi All,

 

I'm trying to set up 3 GPIO pins on the C200 F28335 DSP as just outputs. This is my setup code:

GpioCtrlRegs.GPCPUD.bit.GPIO87 = 1;

GpioCtrlRegs.GPCPUD.bit.GPIO86 = 1;

GpioCtrlRegs.GPCPUD.bit.GPIO85 = 1;

GpioCtrlRegs.GPCMUX2.bit.GPIO87 = 0;

GpioCtrlRegs.GPCMUX2.bit.GPIO86 = 0;

GpioCtrlRegs.GPCMUX2.bit.GPIO85 = 0;

 

GpioDataRegs.GPCSET.bit.GPIO87 = 1;

GpioDataRegs.GPCSET.bit.GPIO86 = 1;

GpioDataRegs.GPCSET.bit.GPIO85 = 1;

 

I'd like to write the bits individully, but I'm getting nothing on the output. I'm using the following (example) to write to the output:

 

   

GpioDataRegs.GPCDAT.bit.GPIO85 = 0;

GpioDataRegs.GPCDAT.bit.GPIO86 = 0;

GpioDataRegs.GPCDAT.bit.GPIO87 = 1;

 

But I'm getting nothing at the output! Any help?

 

  • Read, Modify write instructions will cause this problem. Use GPATOGGLE, GPASET and GPACLEAR to set values on the gpio. Also for additional information on this refer to www.ti.com/lit/an/spraa85c/spraa85c.pdf

    Vivek

  • Anthony,

    Did you set the corresponding GPxDIR bits to configure the pins as output?

    -Tommy

  • Vivek,

    Ok, so reading what you suggested, I'm assuming I load the data into the GPCDAT then the same data into GPCSET to output it, and GPCCLEAR to clear the output? the books don't give a very clear answer to it, I read through SPRUFB0D as well...

     

    Tommy,

    I did have GPCDIR set as output, thanks, forgot to add that information.

     

    Tony

     

  • Did you use our good friend EALLOW before writing to the GpioCtrlRegs registers?

    EDIT: You can use the GPxDAT registers OR the GPxSET/CLR registers.  You do not need to use both.  It is recommended to use SET/CLR when possible.

  • Hi Tony,

    Don't use DAT registers at all for setting values on the pins. Use them only for reading. For setting values use only SET, CLEAR and TOGGLE registers. Automatically these values will be latched on to the particular pins. And it also avoids the read, modify and write problems that occur while programming with DAT registers.

    Vivek

  • Ok, so I am using the DAT registers, I'll try the SET/CLEAR instead and see if that helps. Port Direction was set properly, pullups enabled, but I got no data. the pins just stayed high. I'll try using set/clear today and post results.

     

  • Ok, No luck.

    Here's the setup:

     

    EALLOW

                GpioCtrlRegs.GPCDIR.all = 0x0000E000;      

                 

                // Setup for GPIO

                GpioCtrlRegs.GPCPUD.bit.GPIO87 = 0;

                GpioCtrlRegs.GPCPUD.bit.GPIO86 = 0;

                GpioCtrlRegs.GPCPUD.bit.GPIO85 = 0;

                for (i=0; i<1000; i++) {}

     

                GpioCtrlRegs.GPCMUX2.bit.GPIO87 = 0;

                GpioCtrlRegs.GPCMUX2.bit.GPIO86 = 0;

                GpioCtrlRegs.GPCMUX2.bit.GPIO85 = 0;

                for (i=0; i<1000; i++) {}

     

                GpioDataRegs.GPCSET.bit.GPIO87 = 1;

                GpioDataRegs.GPCSET.bit.GPIO86 = 1;

                GpioDataRegs.GPCSET.bit.GPIO85 = 1;

                for (i=0; i<1000; i++) {}

                EDIS;

     

    and here's the code section to flip bits:

     

                GpioDataRegs.GPCCLEAR.bit.GPIO85 = 1;

                GpioDataRegs.GPCCLEAR.bit.GPIO86 = 1;

                GpioDataRegs.GPCCLEAR.bit.GPIO87 = 1;

     

                volatile Uint16 i;

                for (i=0; i<3700; i++) {}

     

                GpioDataRegs.GPCSET.bit.GPIO85 = 1;

                GpioDataRegs.GPCSET.bit.GPIO86 = 1;

                GpioDataRegs.GPCSET.bit.GPIO87 = 1;

     

    what am I missing or not seeing?

     

  • Anthony Scarnici said:

                GpioCtrlRegs.GPCDIR.all = 0x0000E000;      

    For GPIO85-GPIO87 to be output, GPCDIR should be:  GpioCtrlRegs.GPCDIR.all |= 0x00E00000;

  • Wow, Really? I feel dumb... I should have caught that... Thanks for all the help!!

  • Hi, I am using F28335 DSP controller for Speed controll of a motor.

    I am trying to configure the gpio for 3 analog input (current I1, I2, and theta in phase )and 1 output  .

    Please can any 1 help me how do i do abt it.

    Here is my sample code.

    //  3 bits to input analog Data to LCD

    struct GPACTRL_BITS {          // bits   description

       Uint16 GPIO0:1;            // 0      GPIO0     analog input (current)

       Uint16 GPIO1:1;            // 1      GPIO1     analog input (current)

       Uint16 GPIO2:1;            // 2      GPIO2     analog input (theta in Phase)

     };

    // 1 bit to  output  modes on lcd

    struct GPADAT_CMD_BITS {

                    Uint16 GPIO4:1;            // 0-4     GPIO4     // outbit

                    };

    union GPACTRL_REG {

                    Uint16             all;

    struct GPACTRL_BITS  bit;        // accessing the analog input bits inside  the GPA reg and using only   3 bits out of  8

    };

    union GPADAT_CMD {

                    Uint16                                      all;

                    struct GPADAT_CMD_BITS bit;

    }; // 1 output

    struct GPACTRL_inp_REGS {

                    union GPACTRL_REG GPACTRL;

    };

    struct GPACTRL_CMD_REGS {

                    union GPADAT_CMD GPACTRLCMD;

    };

    ***************************************************************************************************

    Can some one help me to do correct way of coding.

    Thanks in advance.

  • Can please some one reply for configuring GPIO of the controller  F28335. i need to configure 4  analog inputs and 6 digital inputs and, 5 corresponding outputs.

    Thank You

  • Hi i am doing a motor controller project using F28335 controller and need to configure 10 INPUT gpios and 5 output gpios.

    Please reply how to do coding.

    Thank You

  • Hi Roopa,

    First check whether the Analog Pins have Mux capability or are they always assigned to ADC inputs. Then first you need to configure the analog pins using for AIO operation using AIOMUX register. Then set the direction of the pin using AIODIR register

    Vivek