//LPC2103,周立功公司的ARM產(chǎn)品。//在此處,每行未,使用了一個(gè)反斜,表示,上下行
本文引用地址:http://m.butianyuan.cn/article/201611/318987.htm//為一個(gè)整體,這樣寫(xiě)方便修改和理解,設(shè)定。
//沒(méi)寫(xiě)完,要注意。以后,多引用這種方法。
// PINSEL1 = PINSEL1 & (~(0x03 << 2)|~(0x3<<4)|~(0x3<<6));//錯(cuò)誤 置0用&而不是用或的
PINSEL1 = ( PINSEL1 // 在P0。0~P0。15后,劃入PINSEL1,每2位PINSEL
//一個(gè)位; 而IO0DIR是一對(duì)1的。
& (~(0x03 << 2) //設(shè)定P0。17
&(~(0x3<<4)) // P0。18
&(~(0x3<<6))));
#include "config.h"
# define LED1 1 << 17
# define LED2 1 << 18
# define LED3 1 << 19
# define LEDCON LED1|LED2|LED3
void DelayNS (uint32 uiDly)
{
uint32 i;
for (; uiDly > 0; uiDly--){
for(i = 0; i < 50000; i++);
}
}
int main (void)
{
// PINSEL0|&= (~)
uint32 k;
PINSEL1=0xffffffff;
//PINSEL1=0;
// PINSEL1 = PINSEL1 & (~(0x03 << 2)|~(0x3<<4)|~(0x3<<6));
PINSEL1 = PINSEL1 & (~(0x03 << 2));
//置0用與,&=,置1用或|=
//PINSEL1 |=( (~(0x03<<4)));// PINSEL1
// PINSEL1 = PINSEL1 |(~(0x03 << 2)|~(0x3<<4));
// PINSEL1 = PINSEL1 & (~(0x03 << 4));
// PINSEL1 = PINSEL1 & (~(0x03 << 2)|~(0x3<<4)|~(0x3<<6));//錯(cuò)誤 置0用&而不是用或的
PINSEL1 = (PINSEL1 & (~(0x03 << 2)&(~(0x3<<4))&(~(0x3<<6))));
k=PINSEL1;
IO0DIR = LED1;
IO0DIR |=LEDCON;
IO0SET = LED1;
while (1) {
IO0SET = LED1;
DelayNS(50);
IO0CLR = LED1;
DelayNS(50);
IO0SET = LEDCON;
DelayNS(50);
IO0CLR = LEDCON;
DelayNS(50);
}
return 0;
}
評(píng)論