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.

CCS/MSP432P401R: expression must be a modifiable lvalue

Part Number: MSP432P401R


Tool/software: Code Composer Studio

 The following error was encountered while assigning structure variables

compareConfig_PWM1.compareValue

erro:expression must be a modifiable lvalue

This structure is in timer_ a. h inside           

The variable is compareValue

  • #include "steer.h


    /* Timer_A UpDown Configuration Parameter */
    const Timer_A_UpDownModeConfig upDownConfig =
    {
    TIMER_A_CLOCKSOURCE_SMCLK, // SMCLK Clock SOurce
    TIMER_A_CLOCKSOURCE_DIVIDER_8, // SMCLK/1 = 3MHz
    30000, // 127 tick period
    TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt
    TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0 interrupt
    TIMER_A_DO_CLEAR // Clear value

    };

    /* Timer_A Compare Configuration Parameter (PWM1) */
    const Timer_A_CompareModeConfig compareConfig_PWM1 =
    {
    TIMER_A_CAPTURECOMPARE_REGISTER_1, // Use CCR1
    TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable CCR interrupt
    TIMER_A_OUTPUTMODE_TOGGLE_SET, // Toggle output but
    29250 // 32 Duty Cycle
    };

    /* Timer_A Compare Configuration Parameter (PWM2) */
    const Timer_A_CompareModeConfig compareConfig_PWM2 =
    {
    TIMER_A_CAPTURECOMPARE_REGISTER_2, // Use CCR2
    TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable CCR interrupt
    TIMER_A_OUTPUTMODE_TOGGLE_SET, // Toggle output but
    26250 // 96 Duty Cycle
    };
    void Servo_TurnAngle(float value)
    {
    float f_cycle;
    f_cycle = (30000-3000/180)*value;//angle
    compareConfig_PWM1.compareValue = f_cycle;//new pulse       erro: expression must be a modifiable lvalue
    // TIM2_PwmConfig.dutyCycle = (INT16U)f_cycle;//new pulse
    MAP_Timer_A_initCompare(TIMER_A1_BASE, &compareConfig_PWM1);
    };

    timer_a.h 

    typedef struct _Timer_A_CompareModeConfig
    {
    uint_fast16_t compareRegister;
    uint_fast16_t compareInterruptEnable;
    uint_fast16_t compareOutputMode;
    uint_fast16_t compareValue;
    } Timer_A_CompareModeConfig;

  • user5363230 said:
    compareConfig_PWM1.compareValue = f_cycle;//new pulse       erro: expression must be a modifiable lvalue

    The compareConfig_PWM1 variable has been declared as const qualified, which explains the error:

    user5363230 said:
    const Timer_A_CompareModeConfig compareConfig_PWM1 =