当前位置:网站首页>MCU case -int0 and INT1 interrupt count
MCU case -int0 and INT1 interrupt count
2022-07-05 22:21:00 【kdnnnd】
Single chip microcomputer case
combination proteus and keil
INT0 And INT1 Interrupt count
Schematic diagram

Program
/* name :INT0 and INT1 Interrupt count explain : Press the count key K1 The count value is displayed on the right nixie tube , Press the count key K2 The count value is displayed on the left nixie tube , Press the reset key K3,K4 Nixie tube reset */
#include<reg51.h>
#include<intrins.h>
#define INT8U unsigned char
#define INT16U unsigned int
sbit K3=P3^4;// Zero clearing
sbit K4=P3^5;
// Co anode 0-9 Digital tube segment code table
code INT8U CA_Table[]=
{
0xC0,0xF9,
0xA4,0xB0,
0x99,0x92,
0x82,0xF8,
0x80,0x90,
0xFF// Black screen
};
code INT8U scan_bits[]=
{
0x20,0x10,
0x08,0x04,
0x02,0x01
};
// Display buffer of two sets of counts , front 3 For a group , after 3 A group of
INT8U show_buffer[]=
{
0,0,0,
0,0,0
};
INT16U count_a=0;
INT16U count_b=0;
// Time delay
void delay_ms(INT16U x)
{
INT8U t;
while(x--)
{
for(t=0;t<120;t++);
}
}
// The nixie tube displays the count value
void refresh_show()
{
INT8U i;
// decompose count_a
show_buffer[5]=count_a/100;
show_buffer[4]=count_a%100/10;
show_buffer[3]=count_a%10;
if(show_buffer[5]==0)// The high position is 0 Time does not show
{
show_buffer[5]=10;
// The high position is 0 when , The second is 0, It doesn't show
if(show_buffer[4]==0)
show_buffer[4]=10;
}
// decompose count_b
show_buffer[2]=count_b/100;
show_buffer[1]=count_b%100/10;
show_buffer[0]=count_b%10;
if(show_buffer[2]==0)// The high position is 0 Time does not show
{
show_buffer[2]=10;
// The high position is 0 when , The second is 0, It doesn't show
if(show_buffer[1]==0)
show_buffer[1]=10;
}
for(i=0;i<6;i++)
{
P0=0xFF;// Temporarily close the segment code
P2=scan_bits[i];// Bit code
P0=CA_Table[show_buffer[i]];// Segment code
delay_ms(1);
}
}
void main()
{
IT0=1;// Falling edge trigger
IT1=1;
PX0=1;// set priority
IE=0x85;// allow INT0,INT1 interrupt
while(1)
{
if(!K3)// Zero clearing
count_a=0;
if(!K4)// Zero clearing
count_b=0;
refresh_show();// Continue to refresh the display
}
}
//INT0 Interrupt function
void ex_int0() interrupt 0
{
EA=0;// No interruptions
delay_ms(10);// Desquamation
count_a++;// The count is incremented
EA=1;// Open the interrupt
}
//INT1 Interrupt function
void ex_int1() interrupt 2
{
EA=0;// No interruptions
delay_ms(10);// Desquamation
count_b++;// The count is incremented
EA=1;// Open the interrupt
}
边栏推荐
- "Chris Richardson microservices series" uses API gateway to build microservices
- database mirroring
- Overview of concurrency control
- Hcip day 16
- 笔记本电脑蓝牙怎么用来连接耳机
- Evolution of large website architecture and knowledge system
- 解决thinkphp启动时“No input file specified”的问题
- U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
- Overview of database recovery
- Type of fault
猜你喜欢

Installation of VMware Workstation

The simple problem of leetcode is to split a string into several groups of length K

Business learning of mall commodity module

Performance monitoring of database tuning solutions

boundary IoU 的计算方式

IIC bus realizes client device

Stored procedures and stored functions

Database tuning solution

"Chris Richardson microservices series" uses API gateway to build microservices

Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
随机推荐
A trip to Suzhou during the Dragon Boat Festival holiday
Form artifact
Postman核心功能解析-参数化和测试报告
科技云报道:算力网络,还需跨越几道坎?
元宇宙中的三大“派系”
微服务链路风险分析
Nacos installation and service registration
Pl/sql basic syntax
EasyCVR集群部署如何解决项目中的海量视频接入与大并发需求?
如何向mongoDB中添加新的字段附代码(全)
[groovy] mop meta object protocol and meta programming (execute groovy methods through metamethod invoke)
微服務鏈路風險分析
Web3为互联网带来了哪些改变?
GWT module may need to be (RE) compiled reduce - GWT module may need to be (RE) compiled reduce
thinkphp5.1跨域问题解决
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
Oracle triggers
Performance testing of software testing
Platformio create libopencm3 + FreeRTOS project
Leetcode simple question: the minimum cost of buying candy at a discount