CC2530 Basic Experiment 1 I/O Experiment Code
[Copy link]
Code
#include "ioCC2530.h" //reference CC2530 header file
/**************************************************************
Function name: delayFunction
: software delay
Input parameter: time--delay loop execution times
Output parameter: none
Return value: none
***********************************************************/
void delay(unsigned int time)
{
unsigned int i;
unsigned char j;
for(i = 0;i < time;i++)
for(j = 0;j < 240;j++)
{
asm("NOP");//asm is used to embed assembly language operations in C code,
asm("NOP");//compilation command nop is a no-operation, consuming 1 instruction cycle.
asm("NOP");
}
}
/******************************************************************
Function name: mainFunction
: main function of program
Input parameter: none
Output parameter: none
Return value: none
**************************************************************/
void main(void)
{
P1SEL &= ~0xff;//Set all bits of P1 port to normal IO port
P1DIR |= 0xff;//Set all bits of P1 port to output port
while(1) //main loop of program
{
P1 = ~P1; //P1 port output status inversion
delay(1000); //delay
}
}
|