当前位置:网站首页>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
}
边栏推荐
- 如何快速体验OneOS
- opencv 判断点在多边形内外
- GWT module may need to be (RE) compiled reduce - GWT module may need to be (RE) compiled reduce
- The statistics of leetcode simple question is the public string that has appeared once
- Summary of concurrency control
- Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference
- Nacos 的安装与服务的注册
- MySQL服务莫名宕机的解决方案
- 點到直線的距離直線的交點及夾角
- 点到直线的距离直线的交点及夹角
猜你喜欢

What changes has Web3 brought to the Internet?

90后测试员:“入职阿里,这一次,我决定不在跳槽了”

The statistics of leetcode simple question is the public string that has appeared once

700. Search in a Binary Search Tree. Sol

Pl/sql basic syntax

Performance monitoring of database tuning solutions

点到直线的距离直线的交点及夹角

boundary IoU 的计算方式

Interprocess communication in the "Chris Richardson microservice series" microservice architecture

Calculation method of boundary IOU
随机推荐
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
Damn, window in ie open()
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
How to create a thread
元宇宙中的三大“派系”
Analyse des risques liés aux liaisons de microservices
解决thinkphp启动时“No input file specified”的问题
FBO and RBO disappeared in webgpu
如何快速体验OneOS
QT creator 7 beta release
Interview questions for famous enterprises: Coins represent a given value
The statistics of leetcode simple question is the public string that has appeared once
Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
Official clarification statement of Jihu company
Golang writes the opening chapter of selenium framework
Qtquick3d real time reflection
database mirroring
Nacos installation and service registration
笔记本电脑蓝牙怎么用来连接耳机