当前位置:网站首页>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 )
边栏推荐
- Technologists talk about open source: This is not just using love to generate electricity
- Zzuli:1064 encrypted characters
- Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
- Web页面用户分步操作引导插件driver.js
- CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现
- 死磕大屏UI,FineReport开发日记
- Zzuli:1065 count the number of numeric characters
- c语言中的几个关键字
- php数组转化为xml
- Pytorch Chinese document
猜你喜欢

TI毫米波雷达学习(一)

3D 打印机 G 代码命令:完整列表和教程

idea開發工具常用的插件合集匯總

ESP8266与STC8H8K单片机联动——天气时钟

Go language web development is very simple: use templates to separate views from logic

Eco express micro engine system has supported one click deployment to cloud hosting

RGB infinite cube (advanced version)

Reading notes of cgnf: conditional graph neural fields

Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles

Practice C language advanced address book design
随机推荐
mysql的约束总结
VSCode paste image插件保存图片路径设置
运动健身的一些心得经验
Win10 copy files, save files... All need administrator permission, solution
[Chongqing Guangdong education] selected reading reference materials of British and American literature of Nanyang Normal University
Generics and generic constraints of typescript
php按照指定字符,获取字符串中的部分值,并重组剩余字符串为新的数组
Basic use of form
Redis Key-Value数据库【初级】
数据库学习总结5
Vscode paste image plugin saves image path settings
Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
idea開發工具常用的插件合集匯總
Zzuli:1060 numbers in reverse order
Zzuli: maximum Convention and minimum common multiple
Regular expression summary
Typora installation (no need to enter serial number)
Zzuli:1067 faulty odometer
c语言中的几个关键字
all3dp.com网站中全部Arduino项目(2022.7.1)