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.

Neither GPADAT nor GPACLEAR is clearing GPIO pins

Hello,

I'm using the F28069 Experimenter's kit. 

When my program starts, I would like to set all of the pins to GPIO, direction to output, and value to low. This is so I can easily check if I'm initializing all the pins to the correct value later on. This is the code I'm using to do this:

EALLOW;

GpioCtrlRegs.GPAMUX1.all &= 0x00000000;
GpioCtrlRegs.GPAMUX2.all &= 0x00000000;
GpioCtrlRegs.GPADIR.all &= 0xFFFFFFFF;
GpioDataRegs.GPACLEAR.all |= 0xFFFFFFFF;

EDIS;

Unfortunately, when I set a breakpoint after these lines of code and I check the GPADAT values within the expressions, not all of them are 0. There are 2 or 3 GPIOs that have values of 1. Not only that, but when I try to manually change the values in the expressions window, it won't let me change the value of 1 to a value of 0. 

Here are some things I've tried doing to resolve the issue:

- Using GPADAT.all = 0x00000000; instead of GPACLEAR. 

- Individually coding the pins by each bit with GPADAT = 0 and GPACLEAR = 1

- Trying both GPADAT and GPACLEAR

- Adding asm("NOP") in between each line of code

- Trying a different C2000 Experimenter's Kit

Any ideas what might be going wrong? I can just skip these pins and move on (it tends to be the same pins each time that are held at 1), but it would be nice to see what the cause of this issue is and to be able to fix it.

Best,

Matt

  • Hi,

    Please use below gpio configuration & check

    EALLOW;
    GpioCtrlRegs.GPAPUD.all = 0x00000000; // Enable pullup on GPIOA
    GpioDataRegs.GPASET.all = 0xFFFFFFFF; // Load output latch
    GpioCtrlRegs.GPAMUX1.all = 0x00000000; // GPIOA Mux1
    GpioCtrlRegs.GPAMUX2.all = 0x00000000; // GPIOA Mux1
    GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF; // GPIOA output
    GpioDataRegs.GPACLEAR.all = 0xFFFFFFFF;
    EDIS;

    Regards
    Aditya
  • Matt,

    Has this issue been resolved?

    -Lori
  • Hello Aditya,

    I had similar problem and with your solution it is working fine now. Thanks.

    Can you please enplane why?  Why first of all you load the output latch and then you are clearing it?

    Now I want to make some of the GPIOs as inputs. I'm using Experimenter kit TMS320C2000 with F28335.

    These pins are unconnected right now. If in your code I will just change the following

    GpioCtrlRegs.GPADIR.all = 0x00000000; // GPIOA input

    All the inputs will be '1' - due to Pull up enable I guess - why this is different from the output behavior.

    Then if I also change the following:

    GpioCtrlRegs.GPAPUD.all = 0xFFFFFFFF; // Disable pullup on GPIOA

    Some of the GPIOs will be 1 and some of them will be 0 - why?

    Is it due to the fact that they are not connected?

    In general I need to have a stable ZERO on all my inputs.

    Thanks,

    Alex

  • Hi Alex,

    In original code from Matt, the direction of the pins were not getting changed to output. Following was the code which he was using-

    GpioCtrlRegs.GPADIR.all &= 0xFFFFFFFF;

    By default the values of DIR bit in this is '0' and if you and it with '1' it'll be still '0' which means PINs were INPUT only and in that case one can not control the state of the PINs via DATA registers.

    All the inputs will be '1' - due to Pull up enable I guess - why this is different from the output behavior.

    Pulls are applicable when PINs are in Hi-Z state. In output mode pins will be driven by GPIO DATA register hence PULL has not effect.

    Then if I also change the following:

    GpioCtrlRegs.GPAPUD.all = 0xFFFFFFFF; // Disable pullup on GPIOA

    Some of the GPIOs will be 1 and some of them will be 0 - why?

    Is it due to the fact that they are not connected?

    Yes, it's because PINs are floating which should be avoided.

     In general I need to have a stable ZERO on all my inputs.

    For that you need to have pull-down on boards on these PINs.

    Regards,

    Vivek Singh

  • Thank you for your answer!