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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,128 次查看
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 ?

标签 (4)
0 项奖励
回复
1 回复

761 次查看
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 项奖励
回复