- 打卡等级:偶尔看看II
- 打卡总天数:26
- 最近打卡:2025-06-16 09:23:07
版主
- 积分
- 2665

|
打卡第一集 I/O口模式设置和传统的外部中断
程序:
#include <AI8051U.H>
#include "set_int.h"
#include "set_io.h"
#include "intrins.h"
void Delay1ms(void) //@40.000MHz
{
unsigned long edata i;
_nop_();
_nop_();
_nop_();
i = 9998UL;
while (i) i--;
}
void main(void)
{
EAXFR = 1;
CKCON = 0;
WTST = 0;
set_io_mode(pu_mode,Pin40,Pin00,Pin01,Pin02,Pin03,Pin_End);
P40 = 0;
//set_io_mode(pp_mode,Pin40,Pin00,Pin01,Pin_End);
set_io_mode(hz_mode,Pin32,Pin33,Pin34,Pin35,Pin_End);
set_io_mode(en_pur,Pin32,Pin33,Pin34,Pin35,Pin_End);
Delay1ms();
//set_io_mode(dis_pur,Pin32,Pin33,Pin_End);
set_int_mode(falling_edge_mode,Int0,Int1,Int_End);
//set_int_mode(rising_falling_edge_mode,Int0,Int1,Int_End);
EA = 1;
while(1)
{
if(get_int_state(INT0))
{
P00 = ~P00;
}
if(get_int_state(INT1))
{
P01 = ~P01;
}
P02 = P34;
P03 = P35;
}
}
IO.zip
(76.33 KB, 下载次数: 10)
|
|