LPCOpen : Why we use '~' in the Reseved bits masks for registers ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPCOpen : Why we use '~' in the Reseved bits masks for registers ?

1,132 Views
karthikvenkates
Contributor II

Hi,

Below is the snapshot from "syscon_8xx.h" file of lpcopen library. If you see, everywhere they have used '~'.

pastedImage_1.png

For example, take SYSAHBCLKDIV register in LPC812.

pastedImage_2.png

Here Bits <31:8> are reserved bits. We could have defined

#define SYSCTL_SYSAHBCLKDIV_RESERVED    (0xffffff)

But why did LPCOpen use      #define SYSCTL_SYSAHBCLKDIV_RESERVED    (~0xff)       instead ?

Labels (4)
0 Kudos
Reply
1 Reply

765 Views
BlackNight
NXP Employee
NXP Employee

The '~' operator is a 'binary-negate' operator in C. The reserved bitmask would be 0xFFFFFF00 (and not 0xFFFFFF as you wrote). And ~0xFF will be exactly that 0xFFFFFF00. You could use both notations. I would prefer 0xFFFFFF00 too, but ~0xFF is shorter :-).

I hope this helps,

Erich

0 Kudos
Reply