CC2530点亮第一个led灯
创建工程可以查看我的上一篇文章
下面是代码
#include <stdio.h>
#include "main.h"
void INITLED(){
P1SEL &= 0x03;
P1DIR |= 0x03;
P1INP &= 0x03;
P2INP |= 0x40; //下拉
}
void display(uint x){
for(uint i=0;i<x;i++)
for(uint j=0;j<535;j++);
}
void main(){
INITLED();
LED1 = 1;
while(1){
display(1000);
LED1 = ~LED1;
printf("LED1= %d\n",LED1);
}
}
他的配置main.h文件代码为
#include <ioCC2530.h>
typedef unsigned int uint;
typedef unsigned char uchr;
#define LED1 P1_0 //led1
#define LED2 P1_1 //led2
这里是按照创思通信的底板原理图来看的。 他的LED1 接在P1_0上。
下面为运行效果图