Re: Using bitwise AND for setting configuration bits? What's all this about
- From: "FreeRTOS.org" <noemail@xxxxxxxxx>
- Date: Fri, 29 Feb 2008 18:19:32 GMT
"Tomás Ó hÉilidhe" <toe@xxxxxxxxxxx> wrote in message
news:eafe2d01-a21d-4f30-9a9d-563f96cfe6eb@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I've been programming the PIC16F684 for a few weeks now, and only
today did I notice the peculiarity of how the configuration bits were
being set:
__CONFIG(FCMDIS & IESODIS & BORDIS & UNPROTECT & MCLRDIS & PWRTEN &
WDTDIS & INTIO);
I would have expected bitwise OR to be used in conjunction with macros
that equate to an exact power of 2, like as follows:
#define FCMDIS 1
#define IESODIS 2
#define BORDIS 4
#define UNPROTECT 8
#define MCLRDIS 16
#define PWRTEN 32
__CONFIG(FCMDIS | IESODIS | BORDIS | UNPROTECT | MCLRDIS | PWRTEN |
WDTDIS | INITO);
Can anyone shed any light on their usage of bitwise AND for setting
config bits?
If you look at the definitions for the constants that are &'ed together you
will see that they define which bit should be cleared, not which bit should
be set. Hence the & rather than the |. I would hazard a guess it is done
this way for simplicity - to minimise the number of definitions you need to
change what would otherwise be the default behaviour.
--
Regards,
Richard.
+ http://www.FreeRTOS.org & http://www.FreeRTOS.org/shop
16 official architecture ports, 5000 downloads per month.
+ http://www.SafeRTOS.com
Certified by TÜV as meeting the requirements for safety related systems.
.
- References:
- Using bitwise AND for setting configuration bits? What's all this about
- From: Tomás Ó hÉilidhe
- Using bitwise AND for setting configuration bits? What's all this about
- Prev by Date: Re: Chuck Falconer top posting again
- Next by Date: Re: Chuck Falconer top posting again
- Previous by thread: Using bitwise AND for setting configuration bits? What's all this about
- Index(es):
Relevant Pages
|
|