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.

compilation error - expression must be a modifiable lvalue

Other Parts Discussed in Thread: MSP430F135

#include<msp430f135.h>
#define LED1 BIT0

#define SCL BIT6                        
#define SDA BIT7                        //serial Address/Data I/O

void Init_I2C_eeprom(void);
void I2C_Start_bit(void);
/*
void I2C_write_byte_eeprom(unsigned char Byte);
int  I2C_send_Ack(void);
void I2C_Stop_bit(void);
*/
void delay(void);

void main(void)
{
    //unsigned char RxData = 0;
    //Config_timer();        
    Init_I2C_eeprom();                                //Initilise I2C
    I2C_Start_bit();                                //Start bit    
//    I2C_write_byte_eeprom(0xA0);                    //write the byte into EEPROM(Slave)

//    I2C_send_Ack();                            //ACK after tranmitt data
//    I2C_Stop_bit();                                //Stop bit
    _BIS_SR(GIE);                           // Enter LPM0 w/ interrupt
}
void Init_I2C_eeprom(void)
{    
    WDTCTL = WDTPW + WDTHOLD;               // Stop watchdog
    P1DIR |= 0x01;                          // Set P1.0 to output direction
    P1OUT |= 0x01;
    
    BCSCTL1 |= RSEL2;
    DCOCTL |= DCO1 + DCO0;                    // by both above two statement Means it will generate 1MHz Internal DCO frequency
        
    //P4SEL = 0x00;                            //(Not needed in this program)All port P4 pin is selected as GPIO  
      
    //SDA lines can be input or output
    //Make SDA and SCL lines input intially  (if Master is receving(reading) data from slave)
    P4DIR |= 0xf0;                            // Serial Clk line  (SCL) selected as input
    //P4DIR |= 0x80;                            // Serial Data line (SDA) selected as input
    
    P4OUT |= 0xf0;
    //P4OUT |= 0x80;
    
    //P4IN &= 0x0040;
    //P4IN &= 0x0080;
        
    SCL = 1;
    SDA = 1;    
}

void I2C_Start_bit(void)
{        
    SCL = 1;                                //Make SCL pin high//high to low transition while SCL = 1
    SDA = 1;                                //Make SDA pin high
    delay();                                //for high to low transition
    SDA = 1;                                //Make SDA pin low
    delay();
}

void delay(void)
{
    unsigned char i;
    for(i=0;i<20;i++);    
}

  • // #define SCL BIT6                        
    // #define SDA BIT7                        //serial Address/Data I/O



  • No this not soultion

  • BIT6 and BIT7 are not meant to be assigned to; they do not represent a particular object, they represent a bitmask you would OR into some object.

    I can't figure out which register you actually intend to modify.  There are no registers containing the string "SCL" or "SDA" in the include file for that device.

    This matter is not a compiler issue; you need to figure out which symbol in msp430f135.h represents the register you are looking for, and the best place to get that answer is in the MSP430 forum.  I think this thread should be moved there.

  • It looks like you are trying to implement I2C by GPIO bit bang. Your fragment implies that P4.7=SDA and P4.6=SCL. Lines like SCL=1 probably mean set the GPIO or P4OUT &= 0x40.

    A Google search would suggest that you are trying to port gpio_i2c.c. I think you need to go back to original source and hand port it over line by line. Your code fragment appears to me a blind text substitution that resulted in statements like SDA=1. The function I2C_Start_bit() appears to incorrect as it does not toggle SCL or SDA.

    Perhaps it might be better to ask if someone has an I2C bit bang implement for your processor. I am not familiar with your processor to ask the right questions,

  • How about:

      64 = 1;
     128 = 1;

    Do they make any sense? Your code:

      SCL = 1;
      SDA = 1;

    means exactly the same. Because SCL is BIT6 which is 64 and SDA is BIT7 which is 128.

**Attention** This is a public forum