Jump to content
Sign in to follow this  
Steven

Assigning Valuse To Constants

Recommended Posts

Header file

#define nrf24l01_CE_IOREGISTER PORTB

#define nrf24l01_CE_PINMASK 0x01

 

C file

nrf24l01_CE_IOREGISTER &= ~nrf24l01_CE_PINMASK;

 

I’m receiving the following compiler error:

c(510): error: left operand must be l-value c(510:9): error: failed to generate expression

 

I understand that this is because im trying to assign a value to a constant. Is there anyway around this???

Share this post


Link to post
Share on other sites

I think i may have discovered my own solution by using the set_bit and clear_bit functions. Does the boost C compiler have a spi.h header file for using the hardware spi on the 16f pics?

Share this post


Link to post
Share on other sites

In C you can not assign a value to a constant (don't confuse this with const variable thought). The expression you quoted will look like this after passing the pre-processor:

 

6 &= ~1

 

This is an assignment expression and in C left side of an assignment expression must be an l-value.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

After much reading I think i have a better grasp of the concept. Thanks for the help. ;) Also does the sourceBoost compiler have a spi.h header for the spi on the 16F pic's?

Share this post


Link to post
Share on other sites
...Also does the sourceBoost compiler have a spi.h header for the spi on the 16F pic's?...

 

There are no SPI libraries or headers supplied in SourceBoost. We recommend to aks on the BoostC programming forum. There are a lot of talented BoostC users there.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...