当前位置:网站首页>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 )
边栏推荐
猜你喜欢
Huawei Hongmeng OS, is it OK?
DRM display framework as I understand it
ESP8266与STC8H8K单片机联动——天气时钟
CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现
GRBL 软件:简单解释的基础知识
Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
Regular expression summary
Mathematical statistics and machine learning
我所理解的DRM显示框架
15 C language advanced dynamic memory management
随机推荐
2022-2-14 learning xiangniuke project - Section 7 account setting
php读文件(读取json文件,转换为数组)
Fundamentals of software testing
Unity Shader 学习笔记(3)URP渲染管线带阴影PBR-Shader模板(ASE优化版本)
Huawei Hongmeng OS, is it OK?
1036 Boys vs Girls
Zzuli:1068 binary number
RGB 无限立方体(高级版)
[whether PHP has soap extensions installed] a common problem for PHP to implement soap proxy: how to handle class' SoapClient 'not found in PHP
Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
PHP array to XML
深度学习分类网络--Network in Network
Vite打包后的dist不能直接在浏览器打开吗
使用sha256文件验证下载的文件
Matplotlib double Y axis + adjust legend position
Alibaba: open source and self-developed liquid cooling data center technology
php数组转化为xml
Redis key value database [primary]
Grbl software: basic knowledge of simple explanation
文件包含漏洞(一)