STC12C5A60S2单片机P4端口寄存器说明可以查看芯片手册,此例程仅供参考
#include <STC12C5A60S2.h>
#include <intrins.h>
void Delay1ms() //@11.0592MHz
{
unsigned char i, j;
_nop_();
i = 11;
j = 190;
do
{
while (--j);
} while (--i);
}
void Delay_ms(unsigned int timer)
{
unsigned int i;
for(i=0; i<timer; i++)
Delay1ms();
}
void main()
{
P4SW = 0xff;
while(1)
{
P40 = 1;
P41 = 1;
P42 = 1;
P43 = 1;
P44 = 1;
P45 = 1;
P46 = 1;
P47 = 1;
Delay_ms(1000);
P40 = 0;
P41 = 0;
P42 = 0;
P43 = 0;
P44 = 0;
P45 = 0;
P46 = 0;
P47 = 0;
Delay_ms(1000);
}
}