当前位置:网站首页>Blue Bridge Cup SCM module code (nixie tube) (code + comments)
Blue Bridge Cup SCM module code (nixie tube) (code + comments)
2022-06-25 06:44:00 【tuygre】
/* The explanation in the previous chapter will not be repeated */
#include "STC15F2K60S2.H"
#include "stdio.h"
/* contain sprintf function */
typedef unsigned char u8;
typedef unsigned int u16;
u8 org[9],tran[9],wei;
u16 count,i;
void close()
{
P0=0;
P2=P2&0X1F|0XA0;
P2=P2&0X1F;
P0=0XFF;
P2=P2&0X1F|0X80;
P2=P2&0X1F;
}
void open()
{
EA=1;
ET0=1;
}
void Timer0Init(void)
{
AUXR |= 0x80;
TMOD &= 0xF0;
TL0 = 0x20;
TH0 = 0xD1;
TF0 = 0;
TR0 = 1;
}
void translate(u8 org[],u8 tran[])
{
u8 k,j,mid;
for(j=0,k=0;j<8;j++,k++)
/*j Corresponding tran Array ,k Corresponding org Array , Because the nixie tube only 8 individual , Finally, the one-to-one correspondence with the nixie tube is tran Array , therefore j increase 8 Next time , The cycle stops */
{
switch(org[k])
{
case '0': mid = 0xc0; break;
case '1': mid = 0xf9; break;
case '2': mid = 0xa4; break;
case '3': mid = 0xb0; break;
case '4': mid = 0x99; break;
case '5': mid = 0x92; break;
case '6': mid = 0x82; break;
case '7': mid = 0xf8; break;
case '8': mid = 0x80; break;
case '9': mid = 0x90; break;
case '-': mid = 0xbf; break;
default: mid = 0xff;
}
if(org[k+1]=='.')
{
mid=mid&0x7f;
k++;
}
/* The eighth digit of the single-chip microcomputer's cathode nixie tube corresponds to the decimal point */
tran[j]=mid;
/* Don't forget to write the translation results into tran Array */
}
}
/* This function is used to set org The contents of the array ‘ translate ’ to tran Array . The connotation of translation is to org The contents in the array are changed into the contents that can be displayed after the SCM reads , And save to tran Array , The principle of transformation refers to the common cathode digital tube */
void display(u8 tran[],u8 wei)
{
P0=0XFF;
P2=P2&0X1F|0XE0;
P2&=0X1F;
/* Blanking , Clear the previous status display , If the SCM display is normal, you can not write */
P0=1<<wei;
P2=P2&0X1F|0XC0;
P2=P2&0X1F;
/* Select a single nixie tube to display */
P0=tran[wei];
P2=P2&0X1F|0XE0;
P2=P2&0X1F;
/* Determine the display content in a single nixie tube */
}
void main()
{
close();
Timer0Init();
open();
while(1)
{
translate(org,tran);
sprintf(org," %4u",(u16)i);
/* take i Assigned to the nixie tube %4u,%4u Represents an unsigned integer that occupies four bits in an array ,sprintf Functions generally transfer integers , floating-point 、 Other types of characters are error prone */
}
}
void stop0() interrupt 1
{
count++;
if(count%1000==0)
{
i++;
count=0;
}
display(tran,wei);
if(++wei==8) wei=0;
}
/* Every second i Add 1, So the system implements the timer function ; Every time 1ms Parameters wei Add 1, The digital tube displays the contents back and forth , Because the speed is too fast , The human eye cannot perceive */Official schematic diagram , The download address of the user manual is as follows :
link :https://pan.baidu.com/s/1y8lRYHxLKojL4_r0PZPYRw
Extraction code :19so
Note cannot insert picture , Relevant information readers themselves look for in the folder .
Study notes for undergraduate students of Nanjing University of Information Engineering , For your reference .
If there is a mistake , contact QQ3182097183.
边栏推荐
- レレ / 蕾蕾
- How do I check swift if two arrays contain the same elements, regardless of the order in which they appear?
- Kubernetes core components etcd details
- Why did Yanjing Beer come here?
- cos(a-b)=cosa*cosb+sina*sinb的推导过程
- Non-contact infrared temperature measurement system for human body based on single chip microcomputer
- Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
- Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
- MSG_ OOB MSG_ PEEK
- Unity获取资源路径
猜你喜欢

Can TCP syn handshake messages transmit data

joda.time获取日期总结

SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-

レレ / 蕾蕾

Kubernetes core components etcd details

Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)

Drosophila played VR and entered nature. It was found that there were attention mechanisms and working memory. The insect brain was no worse than that of mammals

Self adjustment process of MySQL index tree when adding data

sin(a-b)=sina*cosb-sinb*cosa的推导过程

cos(a-b)=cosa*cosb+sina*sinb的推导过程
随机推荐
The five minute demonstration "teaches" actors to speak foreign languages and can seamlessly switch languages. This AI dubbing company has just received a round a financing of 20million US dollars
'how do I create an enumeration with constant values in rust?'- How can I create enums with constant values in Rust?
Esp8266 & sg90 steering gear & Lighting Technology & Arduino
Tp6 interface returns three elements
ACWING/2004. 错字
Simple and complete steps of vivado project
Drosophila played VR and entered nature. It was found that there were attention mechanisms and working memory. The insect brain was no worse than that of mammals
Non-contact infrared temperature measurement system for human body based on single chip microcomputer
mysql 表查询json数据
聚类和分类的最基本区别。
百度地图——入门教程
Self adjustment process of MySQL index tree when adding data
ACWING/2004. 錯字
How to realize hierarchical management of application and hardware in embedded projects
Sophomores majoring in mechanics build a manipulator by hand -- full of compromise
[acnoi2022] the structure of President Wang
Go language library management restful API development practice
Can TCP syn handshake messages transmit data
Single lithium battery 3.7V power supply 2x12w stereo boost audio power amplifier IC combination solution
Cs8126t 3.1w mono ultra low EMI unfiltered class D audio power amplifier IC