打印

LPC2134 IOCLR 有时不工作

[复制链接]
1182|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ljmpbabyrb|  楼主 | 2013-6-6 10:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
LPC, OCL, pc, IO
为什么IO0CLR = 0x01 << 28; 有时不工作?      



我用P0.28和P0.29作为输出控制外部的两个电磁阀,源码如下:
// MAIN_VALVE1
#define MAIN_VALVE1 (0x01 << 28)
#define MAIN_VALVE1_GPIO() PINSEL1 &= ~(0x03 << 24)
#define MAIN_VALVE1_OUT() IO0DIR |= MAIN_VALVE1
#define MAIN_VALVE1_SET() IO0SET = MAIN_VALVE1
#define MAIN_VALVE1_CLR() IO0CLR = MAIN_VALVE1

// MAIN_VALVE2
#define MAIN_VALVE2 (0x01 << 29)
#define MAIN_VALVE2_GPIO() PINSEL1 &= ~(0x03 << 26)
#define MAIN_VALVE2_OUT() IO0DIR |= MAIN_VALVE2
#define MAIN_VALVE2_SET() IO0SET = MAIN_VALVE2
#define MAIN_VALVE2_CLR() IO0CLR = MAIN_VALVE2


if ( (IO0SET & MAIN_VALVE1) == 0 ) //MAIN_VALVE1 -- P0.28

{
MAIN_VALVE1_SET();
g_bVav1_State = VAL_ON;
}
else
{
MAIN_VALVE1_CLR(); //sometimes not work
g_bVav1_State = VAL_OFF;
}



if ( (IO0SET & MAIN_VALVE2) == 0 ) //MAIN_VALVE2 -- P0.29
{
MAIN_VALVE2_SET();
g_bVav2_State = VAL_ON;
}
else
{
MAIN_VALVE2_CLR(); //sometimes not work
g_bVav2_State = VAL_OFF;
}

下面是我的测试数据,在运行过程中,有时MAIN_VALVE1_CLR(); 或MAIN_VALVE2_CLR(); 不工作,造成电磁阀控制混乱。我的这段代码在LPC2132中用没有问题,但在LPC2134上用出现下面奇怪的问题。


2013-06-02 17:17:54,1,1,1,1,84,85,07,85,85,08, data in blue is the previous
cycle
2013-06-02 17:17:54,0,0,1,1,03,69,11,85,85,08,
2013-06-02 17:17:55,0,0,1,1,08,69,16,85,85,08,
2013-06-02 17:17:55,0,0,1,1,12,69,20,85,85,08,
2013-06-02 17:17:56,0,0,1,1,18,69,26,85,85,08,
2013-06-02 17:17:56,0,0,1,1,22,69,30,85,85,08,
2013-06-02 17:17:57,0,0,1,1,27,69,35,85,85,08,
2013-06-02 17:17:57,0,0,1,1,31,69,39,85,85,08,
2013-06-02 17:17:58,0,0,1,1,37,69,45,85,85,08,
2013-06-02 17:17:58,0,0,1,1,42,69,50,85,85,08,
2013-06-02 17:17:59,0,0,1,1,47,69,55,85,85,08,
2013-06-02 17:17:59,0,0,1,1,52,69,60,85,85,08,
2013-06-02 17:18:00,0,0,1,1,57,69,65,85,85,08,
2013-06-02 17:18:00,0,0,1,1,61,69,69,85,85,08,
2013-06-02 17:18:01,0,0,1,1,66,69,74,85,85,08,
2013-06-02 17:18:01,1,1,1,1,02,85,79,85,85,08,
2013-06-02 17:18:02,1,1,1,1,07,85,84,85,85,08,
2013-06-02 17:18:02,1,1,1,0,12,85,04,69,85,08, data in orange is the current
cycle
2013-06-02 17:18:03,1,1,1,0,16,85,08,69,85,08, The big dark red digit 1 is
IO0SET & 2013-06-02 17:18:03,1,1,1,0,22,85,14,69,85,08, MAIN_VALVE1,the
small red digit 1
2013-06-02 17:18:04,1,1,1,0,26,85,18,69,85,08, is g_bVav1_State = VAL_ON.
The big
2013-06-02 17:18:04,1,1,1,0,32,85,24,69,85,08, dark green 1 is IO0SET &
MAIN_VALVE2
2013-06-02 17:18:05,1,1,1,0,36,85,28,69,85,08, The small green 0 is
g_bVav2_State =
2013-06-02 17:18:05,1,1,1,0,41,85,33,69,85,08, VAL_OFF. At 2013-06-02
17:18:02
2013-06-02 17:18:05,1,1,1,0,46,85,38,69,85,08, MAIN_VALVE2_CLR(),not work
2013-06-02 17:18:06,1,1,1,0,50,85,42,69,85,08,
2013-06-02 17:18:06,1,1,1,0,55,85,47,69,85,08,
2013-06-02 17:18:07,1,1,1,0,60,85,52,69,85,08,
2013-06-02 17:18:07,1,1,1,0,65,85,57,69,85,08,
2013-06-02 17:18:08,1,1,1,0,69,85,61,69,85,08,
2013-06-02 17:18:08,1,1,1,0,74,85,66,69,85,08,
2013-06-02 17:18:09,1,1,0,0,79,85,02,85,85,08,
2013-06-02 17:18:09,1,1,0,0,84,85,07,85,85,08, The following vlave state all
wrong
2013-06-02 17:18:10,0,0,0,0,04,69,12,85,85,08,
2013-06-02 17:18:10,0,0,0,0,09,69,17,85,85,08,
2013-06-02 17:18:11,0,0,0,0,13,69,21,85,85,08,
2013-06-02 17:18:11,0,0,0,0,18,69,26,85,85,08,
2013-06-02 17:18:12,0,0,0,0,23,69,31,85,85,08,
2013-06-02 17:18:12,0,0,0,0,28,69,36,85,85,08,


相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝