/**************************************************************
Function implemented: Make the digital tube display 0-5 from left to right on MCD2-DEMO
Chip P IC 18F452
Compiler PI CC -18
XT:4M Hz
********************************************** *******************/
#include "pic18.h"
const unsigned char display_numb[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xd8,0x80,0x90};
unsigned char display_data[6];//0:L 5:R
/******************************************************************
Port initialization
LATC as digital tube segment driver (low effective)
LATA as digital tube bit selection driver (low effective)
***************************************************************/
void init_port(void)
{
LATC=0xff; //
TRISC=0; //Port C is used as a digital tube segment and set to output
ADCON1=0x07;
TR ISA =0; //Port A is used as a digital tube bit selection control pin and set to output
LATA=0xff;
}
/***********************************************************
Delay program
************************************************************/
void delay_1ms(void)
{
unsigned int n;
for(n=0;n<50;n++)
{
NOP();
}
}
void delay_ms(unsigned int time)
{
for(;time>0;time--)
{
delay_1ms();
}
}
/**********************************************************************
The main program
displays 0-5 from left to right
*******************************************************************/
void main(void)
{
unsigned char n;
init_port();
display_data[0]=display_numb[1];//2
display_data[1]=display_numb[0];//1
display_data[2]=display_numb[3];//4
display_data[3]=display_numb[2];//3
display_data[4]=display_numb[5];//6
display_data[5]=display_numb[4];//5
while(1)
{
LATA=0xfe;
for(n=0;n<6;n++)
{
LATC=display_data[n];
delay_ms(1);
LATA=(LATA<<1)+1;
}
}
}
Previous article:877A software simulates I2C communication to read and write 24C02
Next article:PIC microcontroller communication routine
Recommended ReadingLatest update time:2024-11-23 14:57
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Nvidia self-driving car job openings
- What flash space can RSL10 customers use?
- 【GD32-colibri-F350RX】+UART interrupt test
- [Help] Problems encountered in burning Pingtou Ge's scenario-based Bluetooth Mesh nodes and some solutions
- stm32f429i_eval_development schematic
- MSP430FR5969 always fails to initialize SCCB when driving OV7725
- Fast Fourier Transform of Convolution and Correlation of Discrete Sequences
- Which textbook on switching power supplies is better?
- How to understand the entire LCD scanning cycle?
- Design of automatic loading and Flash burning program based on TMS320C6455 DSP