STC12单片机P4端口测试程序

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);
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值