当前位置:网站首页>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 )
边栏推荐
- PHP array to XML
- Spark概述
- c语言中的几个关键字
- Nacos 启动报错 Error creating bean with name ‘instanceOperatorClientImpl‘ defined in URL
- Thunder on the ground! Another domestic 5g chip comes out: surpass Huawei and lead the world in performance?
- Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
- all3dp.com网站中全部Arduino项目(2022.7.1)
- php读文件(读取json文件,转换为数组)
- 死磕大屏UI,FineReport开发日记
- vite如何兼容低版本浏览器
猜你喜欢
随机推荐
【论文翻译】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
文件包含漏洞(二)
RGB infinite cube (advanced version)
Lantern Festival gift - plant vs zombie game (realized by Matlab)
Opencv LBP features
mock-用mockjs模拟后台返回数据
STC8H8K系列汇编和C51实战——数码管显示ADC、按键串口回复按键号与ADC数值
Oled12864 LCD screen
软件测试答疑篇
PHP gets CPU usage, hard disk usage, and memory usage
Unity Shader 学习笔记(3)URP渲染管线带阴影PBR-Shader模板(ASE优化版本)
1037 Magic Coupon
2022-2-14 learning xiangniuke project - Section 7 account setting
495.提莫攻击
2022-2-15 learning xiangniuke project - Section 8 check login status
Gcnet: non - local Networks meet Squeeze excitation Networks and Beyond
php按照指定字符,获取字符串中的部分值,并重组剩余字符串为新的数组
idea開發工具常用的插件合集匯總
vite如何兼容低版本浏览器
Stc8h8k Series Assembly and c51 Real combat - NIXIE TUBE displays ADC, Key Series port reply Key number and ADC value









