当前位置:网站首页>Stc8h8k series assembly and C51 actual combat - keys allow key counting (using falling edge interrupt control)
Stc8h8k series assembly and C51 actual combat - keys allow key counting (using falling edge interrupt control)
2022-07-02 05:55:00 【I don't know who】
Keys allow key counts ( Use falling edge interrupt control )
One 、 subject
Programming to achieve nixie tube display SW17 The number of times the button is pressed , requirement SW18 Control start and stop , That is, press a single number of times SW18 On the premise of , Start recording SW17 Number of presses , Press... Even times SW18 Key , Then clear the count value , Start all over again SW17 The number of keystrokes is counted .
Two 、 Code
#include <stc8h.h>
#include <intrins.h>
void Delay1ms() //@24.000MHz
{
unsigned char i, j;
_nop_();
i = 32;
j = 40;
do
{
while (--j);
} while (--i);
}
void gpio() //gpio Initialize to quasi two-way port , At first, except P30,P31 Others are in high resistance state
{
P0M1 = 0x00; P0M0 = 0x00; // Set as quasi two-way port
P1M1 = 0x00; P1M0 = 0x00; // Set as quasi two-way port
P2M1 = 0x00; P2M0 = 0x00; // Set as quasi two-way port
P3M1 = 0x00; P3M0 = 0x00; // Set as quasi two-way port
P4M1 = 0x00; P4M0 = 0x00; // Set as quasi two-way port
P5M1 = 0x00; P5M0 = 0x00; // Set as quasi two-way port
P6M1 = 0x00; P6M0 = 0x00; // Set as quasi two-way port
P7M1 = 0x00; P7M0 = 0x00; // Set as quasi two-way port
}
u8 code t_display[]={
// Standard font
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71}; //0. 1. 2. 3. 4. 5. 6. 7. 8. 9. -1
u8 code T_COM[]={
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; // Bit code
unsigned int n=0 ;// because n The following values are 1000, It can't be unsigned char type
void Nixie(u8 i, u16 j)
{
P7=~T_COM[i];
P6=~t_display[j];
Delay1ms();
P6 = 0xFF;
}
void Init()
{
EA=1;// Turn on cpu Total interruption
IT0=1;// Edge jump trigger
IT1=1;// Edge jump trigger
EX0=1;
EX1=1;
PX0=0; // External interrupt 0 For high priority
PX1=1; // External interrupt 1 Low priority
}
u8 flag=0; //flag by 1 When sw17 It works
u8 count[2]; // The maximum count limit is set to 99
void main()
{
gpio();
Init();
while(1)
{
Nixie(0,count[0]); // Display ten digits
Nixie(1,count[1]);
}
}
void INT1() interrupt 2
{
Nixie(0,count[0]); // Display ten digits
Nixie(1,count[1]);
flag++; //sw18 Press after flag Value change , initial flag by 0, Press once to open , Even close
if(flag==2)flag=0;
ET1=0;
}
void INT0() interrupt 0
{
Nixie(0,count[0]); // Display ten digits
Nixie(1,count[1]);
count[0]++; // Add... Every time you press 1
if(count[0]==10)
{
count[0]=0;
count[1]++;
if(count[1]==10)
{
count[1]=0;
}
}
ET0=0;
}
Thank you very much for watching !!!
Series articles ——STC8H8K Series compilation 51 actual combat
STC8H8K Series compilation and C51 actual combat —— Realize the running lantern (51 edition )
STC8H8K Series compilation and C51 actual combat —— Realize the running lantern ( Assembly Edition )
STC8H8K Series compilation and C51 actual combat —— Switch control Timer Stopwatch (C51 edition )
STC8H8K Series compilation and C51 actual combat —— Dual interrupt control timer flow lamp
STC8H8K Series compilation and C51 actual combat —— Double interrupt plus and minus counter
STC8H8K Series compilation and C51 actual combat —— Simple frequency meter
STC8H8K Series compilation and C51 actual combat —— Second countdown timer ( Assembly Edition )
STC8H8K Series compilation and C51 actual combat —— Second countdown timer (51 edition )
STC8H8K Series compilation and C51 actual combat —— Keys allow key counts (51 edition )
STC8H8K Series compilation and C51 actual combat —— Keys allow key counts ( Assembly Edition )
边栏推荐
- 使用sha256文件验证下载的文件
- 软件测试 - 概念篇
- Eco express micro engine system has supported one click deployment to cloud hosting
- Zzuli:1061 sequential output of digits
- 《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记
- Test case
- TI毫米波雷达学习(一)
- Résumé de la collection de plug - ins couramment utilisée dans les outils de développement idea
- 深度学习分类网络--Network in Network
- 2022-2-15 learning xiangniuke project - Section 8 check login status
猜你喜欢
How to write good code - Defensive Programming Guide
CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond
Vscode paste image plugin saves image path settings
Redis Key-Value数据库【初级】
文件包含漏洞(一)
2022-2-14 learning xiangniuke project - Section 7 account setting
“简单”的无限魔方
Spark概述
GRBL 软件:简单解释的基础知识
随机推荐
keepalived安装使用与快速入门
PHP inner class name is the same as the inner class method name
servlet的web.xml配置详解(3.0)
[PHP是否安装了 SOAP 扩]对于php实现soap代理的一个常见问题:Class ‘SoapClient‘ not found in PHP的处理方法
Go language web development is very simple: use templates to separate views from logic
1037 Magic Coupon
JS determines whether the mobile terminal or the PC terminal
我所理解的DRM显示框架
Zzuli:1061 sequential output of digits
图片裁剪插件cropper.js
Summary of MySQL constraints
2022-2-15 learning xiangniuke project - Section 8 check login status
Technologists talk about open source: This is not just using love to generate electricity
I want to understand the swift code before I learn it. I understand it
Eco express micro engine system has supported one click deployment to cloud hosting
LCD之MIPI协议的一些说明
STC8H8K系列汇编和C51实战——串口发送菜单界面选择不同功能
深度学习分类网络 -- AlexNet
数据库学习总结5
Balsamiq wireframes free installation