华维科技 单片机程序 单片机开发板 单片机学习板 单片机编程  

 

 

 

 

 

 

                        51 AVR PIC 三星 义隆 合泰 十速 松翰 现代
                                   用宏定义实现单片机的位操作
          日期: 2008-06-09               发表人: 比尔盖茨熊         文章来源: 本站原创,如有转载请注明出处
              

#define Set_Bit(Val, Bitn) (Val|=(1<<Bitn))//位为1
#define Clr_Bit(Val, Bitn) (Val&=~(1<<Bitn))//位为0
#define Com_Bit(Val, Bitn) (Val^=(1<<Bitn))//位取反
#define Get_Bit(Val, Bitn) (Val&(1<<Bitn))//位读取

#define P00 0
#define P01 1
#define P02 2
#define P03 3
#define P04 4
#define P05 5
#define P06 6
#define P07 7

#define Set_P00 Set_Bit(P0,P00)
#define Clr_P00 Clr_Bir(P0,P00)
#define Com_P00 Com_Bit(P0,P00)
#define Get_P00 Get_Bit(P0,P00)

#define Set_P01 Set_Bit(P0,P01)
#define Clr_P01 Clr_Bir(P0,P01)
#define Com_P01 Com_Bit(P0,P01)
#define Get_P01 Get_Bit(P0,P01)




.
.
.
.
.
.


                       

 

                                     返回首页

 

                                          版权所有@华维科技
                                        建议浏览分辨率1024*768