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.

Define Gpio as output

hi,

I have an ezdsp 28335 and i  try to define gpio0 as output, i read the pdf but there is no c example, first i have to use the mux register to select the operation of the pin, then i have to use the gpxdir (x cdb A,B or C) to define as output or input, but how i specify what pin i use? i mind the code  would be something like:

GpioMuxReg.GPAMUX1.?? = 0X0000;

GpioMuxReg.GPADIR.?? = 0X0001;

Wdb the code for the data reg?

Wdb the code for the input qualifier?

Thanks.

Gaston

  • From your code, you are using the header file structures supplied by TI.  The MUX, Dir, Dat, etc structures all have a bit field for each GPIO.  So if you wanted GPIO10 to be an output then the code would be:

           EALLOW;

           GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 0;   // GPIO function
           GpioCtrlRegs.GPADIR.bit.GPIO10 = 1;     //  direction is out

           EDIS;

    You can also use the .all (instead of .bit) to write to the whole register if you want to configure multiple GPIOs at once.

        GpioCtrlRegs.GPAMUX1.all = 0x00000000;  // All GPIO
        GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF;      // All outputs

    To force the pin high or low, use the SET/CLEAR and TOGGLE registers. For example:

           GpioDataRegs.GPASET.bit.GPIO10 = 1;  // Force the pin high

    The DAT register can also be used to force the pin high/low but is not as friendly as the SET/CLEAR/TOGGLE registers.  The DAT register will also read the state of the pin itself on 2833x devices.  The value read is after any input qualification you have on the pin. For the DAT register, read-modify-writes can change pins you don't mean to because there is a delay between changing a pin and when it reads back that value.  

    Lori

     

  • hi,

    way do you use EALLOW and EDIS?

    the input qualifier is the same?

    thanks lori

    Gaston

  • Some registers require that you issue the EALLOW assembly instruction before they can be written to by the CPU.  These are mainly configuration registers.  The EALLOW; instruction is just an alias for the assembly instruction in C - that is: asm("  EALLOW");  This is defined in the header files and peripheral examples.  EDIS disables access by the CPU.  In the documentation you will see a note on registers that are EALLOW protected. 

    For more information, EALLOW/EDIS is explained in detail in the System Control and Interrupts Guide for your device:

    For 28335 that is the following guide in section 5.2:

    http://focus.ti.com/general/docs/techdocsabstract.tsp?abstractName=sprufb0b

    Yes the input qualifier registers are setup to be accessed the same way in the header files.  For reference, the header files for 2833x are here:  

    http://focus.ti.com/docs/toolsw/folders/print/sprc530.html

    Lori

  • Yes the code examples in sprc530 v1.20 is really helpful[;)]

  • When we add:

           EALLOW;

        GpioCtrlRegs.GPAMUX1.all = 0x00000000;  // All GPIO
        GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF;      // All outputs

           EDIS;

    and a

    GpioCtrlRegs.GPAMUX1.all.toggle;

    to our loop, our adc interrupts fail to operate. Any thoughts?

  • Chris Tobin: Is this a separate topic to discuss?  It may be beneficial to split this into an unique thread.

    Also specifying the device you are using is important.

  • Was the same device which is why I placed it here, but ok, will make a new post.

  • Would you be able to provide a snip of your code highlighting your addition of the GPIO register writes?

  • (1) your line: "GpioCtrlRegs.GPAMUX1.all.toggle;" doesn't make sense, it is not a valid variable name nor a valid instruction.

     GpioCtrlRegs.GPAMUX1.all = 0x....    OR        GpioDataRegs.GPATOGGLE.all = 0x....

    (2) There is no relationship between false C-code and a not working ADC - interrupt

     

  • Hi, Sorry I didnt reply, we ended out re-working alot of our code and aren't using the interrupt now. And for the .all.toggle I just never had it copied properly.