This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

GPIO commit reg is read only

Hi,
I am programming a TM4C123GH6PM device from TI and I get an error when trying to modify the GPIO commit register.
It is defined in the GPIOA_Type struct (in C:\Keil_v5\ARM\PACK\Keil\TM4C_DFP\1.0.0\Device\Include\TM4C123\TM4C123GH6PM.h file) as a constant

__I  uint32_t  CR;    /*!< GPIO Commit*/

this makes the compiler to fail with message: "read-only variable is not assignable"
when trying to modify it.
Is this a bug in the header file? How am I supposed to modify this register?

Javi

Parents Reply Children
  • No, I didn't.

    From the datasheet:
    The GPIOCR register is the commit register. The value of the GPIOCR register determines which
    bits of the GPIOAFSEL, GPIOPUR, GPIOPDR, and GPIODEN registers are committed when a
    write to these registers is performed. If a bit in the GPIOCR register is cleared, the data being written to the corresponding bit in the GPIOAFSEL, GPIOPUR, GPIOPDR, or GPIODEN registers cannot
    be committed and retains its previous value. If a bit in the GPIOCR register is set, the data being written to the corresponding bit of the GPIOAFSEL, GPIOPUR, GPIOPDR, or GPIODEN registers
    is committed to the register and reflects the new value.

    So, I do have to set some of the first 8 bits of that register in order to configure the port.
    In previous versions of the header file this problem didn't happen. I wonder why they changed it.

    Anyway, with the workaround I mentioned it works OK

    Regards

  • Might they have added wizard support for configuring the registers during startup, before main() takes over?

    It's quite common to have some processor registers that should be protected from further use - and some processors even allow them to require privileged mode.

  • From the datasheet:

    And is that really all the datasheet has to say about this group of registers? Last I looked, it said something about this entire mechanism not actually existing for the vast majority of GPIOs on that chip.

    So, I do have to set some of the first 8 bits of that register in order to configure the port.

    Actually, you quite likely don't have to, and shouldn't.

  • You keep saying that I don't have to modify that register but you don't explain why, that's not very useful. In Valvano's ARM cortex-M Microcontrollers book he says that you have to do so for some GPIOs ("Last I looked, it said something about this entire mechanism not actually existing for the vast majority of GPIOs on that chip." yes, you are right, there are only a few GPIOs that use this mechanism but that doesn't mean that you can't use them!).
    If the datasheet defines those bits as modifiable it has no sense to define them as read-only in the header file (in previous versions of the file this didn't happen).
    More people found this issue:
    http://www.keil.com/forum/23862/

    Regards