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

getting errors with bdata of type char

iam trying to access char bdata buff1[10]
but getting some syntax errors. i wrote the code as below to access the array

char bdata buff[10]; bit arr07=1;

sbit mybit4 unsigned int i=0; for(i=0;i<=10;i++)
{ mybit4 = buff[i] ^ 4; buff[i]^4=(buff[i]^4&arr07);
}

Parents
  • iam trying to access char bdata buff1[10]

    In that case, you need to read the chapter in the C51 manual about bit-adressable objects and follow all of the guidelines given therein:

    http://www.keil.com/support/man/docs/c51/c51_le_bitaddrobj.htm

    Also, read the instructions on how to post code, which appear over the text box when you are typing your message.

    Additionally, please copy and paste any code you wish to share in this forum. If you re-type it, you run the risk of introducing additional typos which will confuse everyone trying to understand your code.

    char bdata buff[10];
    bit arr07=1;
    
    sbit mybit4
    unsigned int i=0;
    
    for(i=0;i<=10;i++)
    {
      mybit4 = buff[i] ^ 4;
      buff[i]^4=(buff[i]^4&arr07);
    }
    

    1. You're missing a semicolon after the sbit declaration. I assume you re-typed your code and made a typo. If this is not the case, here's the reason for your first syntax error.

    2. The chapter about bit-adressable objects says in the second paragraph:

    "Furthermore, variables declared with the bdata memory type must be global (declared outside the scope of a function)."

    It looks like you did not follow this rule.

    3. The caret "^" operator means an XOR operation, unless it is used in an sbit declaration. You cannot use it outside an sbit declaration to access the bits of a bdata variable.

    See the examples given in the manual.

Reply
  • iam trying to access char bdata buff1[10]

    In that case, you need to read the chapter in the C51 manual about bit-adressable objects and follow all of the guidelines given therein:

    http://www.keil.com/support/man/docs/c51/c51_le_bitaddrobj.htm

    Also, read the instructions on how to post code, which appear over the text box when you are typing your message.

    Additionally, please copy and paste any code you wish to share in this forum. If you re-type it, you run the risk of introducing additional typos which will confuse everyone trying to understand your code.

    char bdata buff[10];
    bit arr07=1;
    
    sbit mybit4
    unsigned int i=0;
    
    for(i=0;i<=10;i++)
    {
      mybit4 = buff[i] ^ 4;
      buff[i]^4=(buff[i]^4&arr07);
    }
    

    1. You're missing a semicolon after the sbit declaration. I assume you re-typed your code and made a typo. If this is not the case, here's the reason for your first syntax error.

    2. The chapter about bit-adressable objects says in the second paragraph:

    "Furthermore, variables declared with the bdata memory type must be global (declared outside the scope of a function)."

    It looks like you did not follow this rule.

    3. The caret "^" operator means an XOR operation, unless it is used in an sbit declaration. You cannot use it outside an sbit declaration to access the bits of a bdata variable.

    See the examples given in the manual.

Children
No data