这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » LPC2XXX LPC2XXX的I/O口简单用!!!!!!!

共2条 1/1 1 跳转至

LPC2XXX LPC2XXX的I/O口简单用!!!!!!!

院士
2006-09-17 18:14:16     打赏
LPC2XXX LPC2XXX的I/O口简单用!!!!!!!



关键词: LPC2XXX     口简     单用    

院士
2006-12-22 22:43:00     打赏
2楼
问 /*********************************************************************
定义P0口各个引脚置一


*********************************************************************/
#define     P0_0_1 IO0SET=IO0SET | 0X01
#define     P0_1_1 IO0SET=IO0SET | (0X01 << 1)       
#define     P0_2_1 IO0SET=IO0SET | (0X01 << 2)     
#define     P0_3_1 IO0SET=IO0SET | (0X01 << 3)     
#define     P0_4_1 IO0SET=IO0SET | (0X01 << 4)     
#define     P0_5_1 IO0SET=IO0SET | (0X01 << 5)     
#define     P0_6_1 IO0SET=IO0SET | (0X01 << 6)     
#define     P0_7_1 IO0SET=IO0SET | (0X01 << 7)     
#define     P0_8_1 IO0SET=IO0SET | (0X01 << 8)     
#define     P0_9_1 IO0SET=IO0SET | (0X01 << 9)     
#define     P0_10_1 IO0SET=IO0SET | (0X01 << 10)     
#define     P0_11_1 IO0SET=IO0SET | (0X01 << 11)     
#define     P0_12_1 IO0SET=IO0SET | (0X01 << 12)     
#define     P0_13_1 IO0SET=IO0SET | (0X01 << 13)     
#define     P0_14_1 IO0SET=IO0SET | (0X01 << 14)     
#define     P0_15_1 IO0SET=IO0SET | (0X01 << 15)     
#define     P0_16_1 IO0SET=IO0SET | (0X01 << 16)     
#define     P0_17_1 IO0SET=IO0SET | (0X01 << 17)     
#define     P0_18_1 IO0SET=IO0SET | (0X01 << 18)       
#define     P0_19_1 IO0SET=IO0SET | (0X01 << 19)     
#define     P0_20_1 IO0SET=IO0SET | (0X01 << 20)     
#define     P0_21_1 IO0SET=IO0SET | (0X01 << 21)     
#define     P0_22_1 IO0SET=IO0SET | (0X01 << 22)     
#define     P0_23_1 IO0SET=IO0SET | (0X01 << 23)     
#define     P0_24_1 IO0SET=IO0SET | (0X01 << 24)     
#define     P0_25_1 IO0SET=IO0SET | (0X01 << 25)     
#define     P0_26_1 IO0SET=IO0SET | (0X01 << 26)     
#define     P0_27_1 IO0SET=IO0SET | (0X01 << 27)     
#define     P0_28_1 IO0SET=IO0SET | (0X01 << 28)     
#define     P0_29_1 IO0SET=IO0SET | (0X01 << 29)     
#define     P0_30_1 IO0SET=IO0SET | (0X01 << 30)     
#define     P0_31_1 IO0SET=IO0SET | (0X01 << 31)     


/*********************************************************************
定义P1口各个引脚置一


*********************************************************************/
/*
#define     P1_0_1 IO1SET=IO1SET | 0X01
#define     P1_1_1 IO1SET=IO1SET | (0X01 << 1)       
#define     P1_2_1 IO1SET=IO1SET | (0X01 << 2)     
#define     P1_3_1 IO1SET=IO1SET | (0X01 << 3)     
#define     P1_4_1 IO1SET=IO1SET | (0X01 << 4)     
#define     P1_5_1 IO1SET=IO1SET | (0X01 << 5)     
#define     P1_6_1 IO1SET=IO1SET | (0X01 << 6)     
#define     P1_7_1 IO1SET=IO1SET | (0X01 << 7)     
#define     P1_8_1 IO1SET=IO1SET | (0X01 << 8)     
#define     P1_9_1 IO1SET=IO1SET | (0X01 << 9)     
#define     P1_10_1 IO1SET=IO1SET | (0X01 << 10)     
#define     P1_11_1 IO1SET=IO1SET | (0X01 << 11)     
#define     P1_12_1 IO1SET=IO1SET | (0X01 << 12)     
#define     P1_13_1 IO1SET=IO1SET | (0X01 << 13)     
#define     P1_14_1 IO1SET=IO1SET | (0X01 << 14)     
#define     P1_15_1 IO1SET=IO1SET | (0X01 << 15) */    
#define     P1_16_1 IO1SET=IO1SET | (0X01 << 16)     
#define     P1_17_1 IO1SET=IO1SET | (0X01 << 17)     
#define     P1_18_1 IO1SET=IO1SET | (0X01 << 18)       
#define     P1_19_1 IO1SET=IO1SET | (0X01 << 19)     
#define     P1_20_1 IO1SET=IO1SET | (0X01 << 20)     
#define     P1_21_1 IO1SET=IO1SET | (0X01 << 21)     
#define     P1_22_1 IO1SET=IO1SET | (0X01 << 22)     
#define     P1_23_1 IO1SET=IO1SET | (0X01 << 23)     
#define     P1_24_1 IO1SET=IO1SET | (0X01 << 24)     
#define     P1_25_1 IO1SET=IO1SET | (0X01 << 25)     
#define     P1_26_1 IO1SET=IO1SET | (0X01 << 26)     
#define     P1_27_1 IO1SET=IO1SET | (0X01 << 27)     
#define     P1_28_1 IO1SET=IO1SET | (0X01 << 28)     
#define     P1_29_1 IO1SET=IO1SET | (0X01 << 29)     
#define     P1_30_1 IO1SET=IO1SET | (0X01 << 30)     
#define     P1_31_1 IO1SET=IO1SET | (0X01 << 31)    





/*********************************************************************
定义P0口各个引脚置零


*********************************************************************/
#define     P0_0_0 IO0CLR=IO0CLR | 0X01
#define     P0_1_0 IO0CLR=IO0CLR | (0X01 << 1)       
#define     P0_2_0 IO0CLR=IO0CLR | (0X01 << 2)     
#define     P0_3_0 IO0CLR=IO0CLR | (0X01 << 3)     
#define     P0_4_0 IO0CLR=IO0CLR | (0X01 << 4)     
#define     P0_5_0 IO0CLR=IO0CLR | (0X01 << 5)     
#define     P0_6_0 IO0CLR=IO0CLR | (0X01 << 6)     
#define     P0_7_0 IO0CLR=IO0CLR | (0X01 << 7)     
#define     P0_8_0 IO0CLR=IO0CLR | (0X01 << 8)     
#define     P0_9_0 IO0CLR=IO0CLR | (0X01 << 9)     
#define     P0_10_0 IO0CLR=IO0CLR | (0X01 << 10)     
#define     P0_11_0 IO0CLR=IO0CLR | (0X01 << 11)     
#define     P0_12_0 IO0CLR=IO0CLR | (0X01 << 12)     
#define     P0_13_0 IO0CLR=IO0CLR | (0X01 << 13)     
#define     P0_14_0 IO0CLR=IO0CLR | (0X01 << 14)     
#define     P0_15_0 IO0CLR=IO0CLR | (0X01 << 15)     
#define     P0_16_0 IO0CLR=IO0CLR | (0X01 << 16)     
#define     P0_17_0 IO0CLR=IO0CLR | (0X01 << 17)     
#define     P0_18_0 IO0CLR=IO0CLR | (0X01 << 18)       
#define     P0_19_0 IO0CLR=IO0CLR | (0X01 << 19)     
#define     P0_20_0 IO0CLR=IO0CLR | (0X01 << 20)     
#define     P0_21_0 IO0CLR=IO0CLR | (0X01 << 21)     
#define     P0_22_0 IO0CLR=IO0CLR | (0X01 << 22)     
#define     P0_23_0 IO0CLR=IO0CLR | (0X01 << 23)     
#define     P0_24_0 IO0CLR=IO0CLR | (0X01 << 24)     
#define     P0_25_0 IO0CLR=IO0CLR | (0X01 << 25)     
#define     P0_26_0 IO0CLR=IO0CLR | (0X01 << 26)     
#define     P0_27_0 IO0CLR=IO0CLR | (0X01 << 27)     
#define     P0_28_0 IO0CLR=IO0CLR | (0X01 << 28)     
#define     P0_29_0 IO0CLR=IO0CLR | (0X01 << 29)     
#define     P0_30_0 IO0CLR=IO0CLR | (0X01 << 30)     
#define     P0_31_0 IO0CLR=IO0CLR | (0X01 << 31)     


/*********************************************************************
定义P1口各个引脚置零


*********************************************************************/
/*
#define     P1_0_0 IO1CLR=IO1CLR | 0X01
#define     P1_1_0 IO1CLR=IO1CLR | (0X01 << 1)       
#define     P1_2_0 IO1CLR=IO1CLR | (0X01 << 2)     
#define     P1_3_0 IO1CLR=IO1CLR | (0X01 << 3)     
#define     P1_4_0 IO1CLR=IO1CLR | (0X01 << 4)     
#define     P1_5_0 IO1CLR=IO1CLR | (0X01 << 5)     
#define     P1_6_0 IO1CLR=IO1CLR | (0X01 << 6)     
#define     P1_7_0 IO1CLR=IO1CLR | (0X01 << 7)     
#define     P1_8_0 IO1CLR=IO1CLR | (0X01 << 8)     
#define     P1_9_0 IO1CLR=IO1CLR | (0X01 << 9)     
#define     P1_10_0 IO1CLR=IO1CLR | (0X01 << 10)     
#define     P1_11_0 IO1CLR=IO1CLR | (0X01 << 11)     
#define     P1_12_0 IO1CLR=IO1CLR | (0X01 << 12)     
#define     P1_13_0 IO1CLR=IO1CLR | (0X01 << 13)     
#define     P1_14_0 IO1CLR=IO1CLR | (0X01 << 14)     
#define     P1_15_0 IO1CLR=IO1CLR | (0X01 << 15)*/     
#define     P1_16_0 IO1CLR=IO1CLR | (0X01 << 16)     
#define     P1_17_0 IO1CLR=IO1CLR | (0X01 << 17)     
#define     P1_18_0 IO1CLR=IO1CLR | (0X01 << 18)       
#define     P1_19_0 IO1CLR=IO1CLR | (0X01 << 19)     
#define     P1_20_0 IO1CLR=IO1CLR | (0X01 << 20)     
#define     P1_21_0 IO1CLR=IO1CLR | (0X01 << 21)     
#define     P1_22_0 IO1CLR=IO1CLR | (0X01 << 22)     
#define     P1_23_0 IO1CLR=IO1CLR | (0X01 << 23)     
#define     P1_24_0 IO1CLR=IO1CLR | (0X01 << 24)     
#define     P1_25_0 IO1CLR=IO1CLR | (0X01 << 25)     
#define     P1_26_0 IO1CLR=IO1CLR | (0X01 << 26)     
#define     P1_27_0 IO1CLR=IO1CLR | (0X01 << 27)     
#define     P1_28_0 IO1CLR=IO1CLR | (0X01 << 28)     
#define     P1_29_0 IO1CLR=IO1CLR | (0X01 << 29)     
#define     P1_30_0 IO1CLR=IO1CLR | (0X01 << 30)     
#define     P1_31_0 IO1CLR=IO1CLR | (0X01 << 31)



这样,就可以随心的LPC2XXX了,跟51单片机的I/O口一样的简单用
如:我定义一个灯LED,
    #define LED_H   P1_26_1
    #define LED_L   P1_26_0
1: 已经收藏,谢谢了啊已经收藏,谢谢了啊 2: 有人捧场,那再来一下!!!!/*********************************************************************
说明:
     此文件定义了测试引脚的标识符(P0口)
     只能用于判断测试引脚是否为低电平
     如:if(TEP0_25 != 0)
               {...;
                ...;
                ...;
               }
*********************************************************************/
#define     TEP0_0 (IO0PIN & 0X01)
#define     TEP0_1 (IO0PIN & (0X01 << 1))       
#define     TEP0_2 (IO0PIN & (0X01 << 2))     
#define     TEP0_3 (IO0PIN & (0X01 << 3))     
#define     TEP0_4 (IO0PIN & (0X01 << 4))     
#define     TEP0_5 (IO0PIN & (0X01 << 5))     
#define     TEP0_6 (IO0PIN & (0X01 << 6))     
#define     TEP0_7 (IO0PIN & (0X01 << 7))     
#define     TEP0_8 (IO0PIN & (0X01 << 8))     
#define     TEP0_9 (IO0PIN & (0X01 << 9))     
#define     TEP0_10 (IO0PIN & (0X01 << 10))     
#define     TEP0_11 (IO0PIN & (0X01 << 11))     
#define     TEP0_12 (IO0PIN & (0X01 << 12))     
#define     TEP0_13 (IO0PIN & (0X01 << 13))     
#define     TEP0_14 (IO0PIN & (0X01 << 14))     
#define     TEP0_15 (IO0PIN & (0X01 << 15))     
#define     TEP0_16 (IO0PIN & (0X01 << 16))     
#define     TEP0_17 (IO0PIN & (0X01 << 17))     
#define     TEP0_18 (IO0PIN & (0X01 << 18))       
#define     TEP0_19 (IO0PIN & (0X01 << 19))     
#define     TEP0_20 (IO0PIN & (0X01 << 20))     
#define     TEP0_21 (IO0PIN & (0X01 << 21))     
#define     TEP0_22 (IO0PIN & (0X01 << 22))     
#define     TEP0_23 (IO0PIN & (0X01 << 23))     
//#define     TEP0_24 (IO0PIN & (0X01 << 24))     
#define     TEP0_25 (IO0PIN & (0X01 << 25))     
#define     TEP0_26 (IO0PIN & (0X01 << 26))     
#define     TEP0_27 (IO0PIN & (0X01 << 27))     
#define     TEP0_28 (IO0PIN & (0X01 << 28))     
#define     TEP0_29 (IO0PIN & (0X01 << 29))     
#define     TEP0_30 (IO0PIN & (0X01 << 30))     
#define     TEP0_31 (IO0PIN & (0X01 << 31))     


/*********************************************************************
说明:
     此文件定义了测试引脚的标识符(P1口)
     只能用于判断测试引脚是否为低电平
     如:if(TEP1_25 == 0)
               {...;
                ...;
                ...;
               }
*********************************************************************/
#define     TEP1_0 (IO1PIN & 0X01)
#define     TEP1_1 (IO1PIN & (0X01 << 1))       
#define     TEP1_2 (IO1PIN & (0X01 << 2))     
#define     TEP1_3 (IO1PIN & (0X01 << 3))     
#define     TEP1_4 (IO1PIN & (0X01 << 4))     
#define     TEP1_5 (IO1PIN & (0X01 << 5))     
#define     TEP1_6 (IO1PIN & (0X01 << 6))     
#define     TEP1_7 (IO1PIN & (0X01 << 7))     
#define     TEP1_8 (IO1PIN & (0X01 << 8))     
#define     TEP1_9 (IO1PIN & (0X01 << 9))     
#define     TEP1_10 (IO1PIN & (0X01 << 10))     
#define     TEP1_11 (IO1PIN & (0X01 << 11))     
#define     TEP1_12 (IO1PIN & (0X01 << 12))     
#define     TEP1_13 (IO1PIN & (0X01 << 13))     
#define     TEP1_14 (IO1PIN & (0X01 << 14))     
#define     TEP1_15 (IO1PIN & (0X01 << 15))     
#define     TEP1_16 (IO1PIN & (0X01 << 16))     
#define     TEP1_17 (IO1PIN & (0X01 << 17))     
#define     TEP1_18 (IO1PIN & (0X01 << 18))       
#define     TEP1_19 (IO1PIN & (0X01 << 19))     
#define     TEP1_20 (IO1PIN & (0X01 << 20))     
#define     TEP1_21 (IO1PIN & (0X01 << 21))     
#define     TEP1_22 (IO1PIN & (0X01 << 22))     
#define     TEP1_23 (IO1PIN & (0X01 << 23))     
#define     TEP1_24 (IO1PIN & (0X01 << 24))     
#define     TEP1_25 (IO1PIN & (0X01 << 25))     
#define     TEP1_26 (IO1PIN & (0X01 << 26))     
#define     TEP1_27 (IO1PIN & (0X01 << 27))     
#define     TEP1_28 (IO1PIN & (0X01 << 28))     
#define     TEP1_29 (IO1PIN & (0X01 << 29))     
#define     TEP1_30 (IO1PIN & (0X01 << 30))     
#define     TEP1_31 (IO1PIN & (0X01 << 31))    

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]