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.

TM4C123GH6PM: Expression must be a modifiable lvalue

Part Number: TM4C123GH6PM

im trying to configure the GPIOF port to interrupt when SW1 (port f pin 4) and SW1 (port f pin 0). the pin 0 requests modifying registers CR and LOCK:

GPIOF->LOCK =0x4C4F434B;
GPIOF->CR |= 0x01;
SYSCTL->RCGCGPIO |= (1<<5); // enable clock on PORT F
GPIOF->AFSEL =0x00; //&= ~(0x1E); // configure as a GPIO pin, not an alternative.
GPIOF->DIR = (0x0E); //input(0)/output(1)
GPIOF->DEN = (0x1F); // digital enable
GPIOF->PUR = (0x11); // pullup

GPIOF->IM = (0x00); //MASK
GPIOF->IS =0x00; //edge_sensitive(0)/level_sensitive(1) //edge triggred
GPIOF->IBE = 0x00; //controlled GPIOIEV(0)/both edges(1)
GPIOF->IEV = (0x00); //falling edge- lowlevel(0)/rising edge-high level(1)
GPIOF->RIS=(0x00); // clear interrupt
GPIOF->IM = (0x11); //UNMASK

but i recieve this message : expression must be a modifiable lvalue in this line GPIOF->CR |= 0x01;

can someone help me? 

Thanks

ps: i'm using IAR Embedded Worbench IDE

  • Hello Guilherme,

    Do you have the following in your includes?

    #include "inc/hw_types.h" /* for definition of HWREG */

    If not, please add that and try to compile again.

    If so, please post the full list of includes.
  • I don't see the structure used defined anywhere. I don't remember any such in TIVAware (it's not a good idea in any case) and I couldn't find it either.

    Robert
  • We strongly recommend that instead of using direct register writes as in your code above you use the TivaWare library routines. This will improve your efficiency as you will be using proven code and will allow easier support from other forum users. For example in this case you would use a call to the function GPIOIntTypeSet(). There is an example given in the driver library documentation on page 285.

  • Robert Adsett said:
    I don't see the structure used defined anywhere. I don't remember any such in TIVAware (it's not a good idea in any case) and I couldn't find it either.

    The coding style appears to make use of CMSIS for Tiva - since on a quick look matches the structure definitions in https://github.com/speters/CMSIS/blob/master/Device/TI/TM4C/Include/TM4C123GH6PM.h 

    I referenced unofficial version of  CMSIS for Tiva on GitHub, since previous threads suggested TI aren't maintaining CMSIS for Tiva .

  • Boa tarde Guilherme,
    I strongly suggest that you erase all of your code and use TivaWare API's to configure your hardware.
    The only thing you achieve by using register attributions like that is a major dor de cabeça.
    Install Tivaware, look at the /docs folder, check this PDF file: SW-TM4C-DRL-UG-2.1.4.178
    Keep it open for the rest of your Tiva development life!
    Regards
    Bruno
  • We seem to be all agreed.

    A little bonus for the OP, a piece of the unlock code I use.

    /*** PortUnlock - Unlock a port so it can be configured.
     ***/
    void PortUnlock(uint32_t port)
    {
        HWREG(port + GPIO_O_LOCK) = GPIO_LOCK_KEY;
        HWREG(port + GPIO_O_CR) = 0xFF;
        HWREG(port + GPIO_O_LOCK) = 0;
    }  

    Expanding that to complete working code is left as an exercise for the reader

    Robert

    I'm a little dismayed (not shocked mind you) that CMSIS uses an unsafe construct such as this.