当前位置:网站首页>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
}
边栏推荐
- [agc009e] eternal average - conclusion, DP
- A trip to Suzhou during the Dragon Boat Festival holiday
- [Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
- 科技云报道:算力网络,还需跨越几道坎?
- Promql demo service
- 1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
- Qtquick3d real time reflection
- New 3D particle function in QT 6.3
- Form artifact
- Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法
猜你喜欢
Oracle hint understanding
點到直線的距離直線的交點及夾角
笔记本电脑蓝牙怎么用来连接耳机
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
Summary of concurrency control
Two stage locking protocol for concurrency control
Qtquick3d real time reflection
Concurrency control of performance tuning methodology
如何快速体验OneOS
元宇宙中的三大“派系”
随机推荐
如何向mongoDB中添加新的字段附代码(全)
Calculation method of boundary IOU
Two stage locking protocol for concurrency control
极狐公司官方澄清声明
Some tutorials install the database on ubantu so as not to occupy computer memory?
The difference between MVVM and MVC
航海日答题小程序之航海知识竞赛初赛
Text组件新增内容通过tag_config设置前景色、背景色
Livelocks and deadlocks of concurrency control
科技云报道:算力网络,还需跨越几道坎?
Metaverse Ape获Negentropy Capital种子轮融资350万美元
Oracle views the data size of a table
Distance from point to line intersection and included angle of line
微服务链路风险分析
Official clarification statement of Jihu company
Overview of concurrency control
请求二进制数据和base64格式数据的预览显示
2022-07-05: given an array, you want to query the maximum value in any range at any time. If it is only established according to the initial array and has not been modified in the future, the RMQ meth
New 3D particle function in QT 6.3
Platform bus