利用了P2口 代码如下
int RunDirect = 0; // 移动方向
main函数
void main(void)
{
/* Start user code. Do not edit comment generated here */
UCHAR LEDS = 0xFE; // 先点亮一个灯
TAU0_Channel0_Start();
while (1U)
{
if(timerflag)
{
P2 = LEDS;
if(RunDirect)
{
LEDS >>= 1;
LEDS |= 0x80;
if(LEDS == 0xFF) // 0b11111111
{
LEDS = 0xFD; // 0b11111101
RunDirect = 0;
}
}
else
{
LEDS <<= 1;
LEDS |= 0x01;
if(LEDS == 0xFF) // 0b11111111
{
LEDS = 0xBF; // 0b10111111
RunDirect = 1;
}
}
timerflag = 0;
}
else
{
NOP();
}
}
/* End user code. Do not edit comment generated here */
}
代码: myRunLEDs.rar
图片等我找个相机
先传一个调试的截图

补充一句
在初始化P2口之后
要记得在main函数中加入一句话
// very important !!
ADPC = _01_ADPC_DI_ON;
否则输出电平有问题
之前没有实际调试 没发现这个这问题
传张照片
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_BEDD22B7CA18F39D_false_EEA982EE6B20F4D1_1/player.swf