#include
__CONFIG(0x3B31);
#defineA0RB0
#defineA1RB1
#defineCSRB2
#defineLERD0
#defineWRRD6
#defineRDRD7
const unsigned chartab[]={0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e, 0xff}; //0-F-all off-common anode digital tube
unsignedchartmp[]={0,0,0,0,0,0,0,0};
voiddelay1ms(unsignedintx)
{
unsignedchari;
for(;x》0;x--)
for(i=0;i《165;i++);
}
voidins()
{
TRISB=0x00;
PORTB=0x00;
TRISD=0x00;
PORTD=0x00;
LE=0;WR=1;RD=1;//Turn off 373, prohibit 8255 reading and writing
}
voidinit_8255()
{
LE=1;A1=1;A0=1;CS=0;//Open 373, send write controller command, CS chip select is allowed
LE=0; //Lock 373, keep A1.A0, CS
PORTB=0x80; //Send control command
WR=0; //Open write 8255 signal
NOP();NOP();
}
voidwrite_data(unsignedcharcomm,unsignedchardata)//comm:0=A,1=B,2=C
{
if(comm==0)
{
WR=1;
LE=1;A1=0;A0=0;CS=0;
LE=0;
PORTB=data;
WR=0;
NOP();NOP();
}
if(comm==1)
{
WR=1;
LE=1;A1=0;A0=1;CS=0;
LE=0;
PORTB=data;
WR=0;
NOP();NOP();
}
if(comm==2)
{
WR=1;
LE=1;A1=1;A0=0;CS=0;
LE=0;
PORTB=data;
WR=0;
NOP();NOP();
}
}
voiddisplay()
{
unsignedchari,LED;
LED=0x01;
for(i=0;i《8;i++)
{
write_data(0,tab[tmp[i]]);
write_data(1,LED);
LED《《=1;
delay1ms(2);
write_data(1,0x00);
}
}
i ca n't
{
unsignedchari,j,RR[24];
heat();
init_8255();
while(1)
{
for (i = 0; i < 24; i ++) // All values are assigned to 16, which means they are displayed as empty. This can be simplified, but it doesn't matter for demonstration purposes.
RR[i]=16;
RR[8]=2;RR[9]=0;RR[10]=0;RR[11]=9;RR[12]=0;RR[13]=7;RR[14]=1;RR[15]=2;
for(j=0;j《16;j++)
{
for (i=0;i<8;i++) // assign RR[16] to tmp[]
tmp[i]=RR[16+i];
for(i=0;i《23;i++)
display();
for(i=23;i》0;i--)//Here, shift RR[] right by one bit in the array
RR[i+1]=RR[i];
}
}
}
Previous article:Temperature measurement program sharing based on PIC microcontroller
Next article:Design of dynamic scanning display of digital tube by PIC single chip microcomputer
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- [RTT & Renesas high performance CPK-RA6M4] 6. Software simulation I2C driver PCF8574 evaluation
- LPC1768 information release
- Filter capacitor value after bridge rectification
- Please look at this circuit, why is the output signal like this, the DC operating point is fine
- [GD32E503 Evaluation] mig29_Step1: Summary of development environment construction issues
- Mobile station development board CC26X2R1 LaunchPad recommended!
- Embedded System Basics: What is a Microcontroller MCU?
- Evaluation board quick test - based on TI Sitara Cortex-A9(3)
- Three-phase watt-hour meter transformer wiring
- #Idle Market# is open, you sell your idle items and I'll give you gifts!