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

Sbit doest work

Hello ALL

I need to access some of the bit positions of the SFR. But each time i tried to declare a variable of the type sbit , i get error C141: syntax error near sbit. I have read the manual and i even tried the statement :

 sbit EA = 0xAF 
but I still get the same error . Can someone help me out!!!

Thanks.

Parents
  • Thanks Davis!
    I think the problem was that I placed the declaration within the main program scope. When i placed the statement

     sbit EA = 0xAF; 
    just after function prototypes, the error cease to exist.

    Hoever, if you have
     Sfr (MMCON0  , 0xE4);
    Sfr (MMCON1  , 0xE5);
    Sfr (MMCON2  , 0xE6); 
    in the header file, and for example, you need to access the second bit of MMCON1, would something like this
     sbit RESPEN = 0xE5 + 1; 
    works? Please, take note of the address of MMCON2.

    Thanks

Reply
  • Thanks Davis!
    I think the problem was that I placed the declaration within the main program scope. When i placed the statement

     sbit EA = 0xAF; 
    just after function prototypes, the error cease to exist.

    Hoever, if you have
     Sfr (MMCON0  , 0xE4);
    Sfr (MMCON1  , 0xE5);
    Sfr (MMCON2  , 0xE6); 
    in the header file, and for example, you need to access the second bit of MMCON1, would something like this
     sbit RESPEN = 0xE5 + 1; 
    works? Please, take note of the address of MMCON2.

    Thanks

Children