// Chip ATMEGA16L
// Clock 4MHz internal
// Use system built-in delay program
#include
#include
#define hc164_da
#define hc164_clk PORTD.1 // 164 clock line
#define CLK549 PORTD.4 // tlc549 clock line, PD4 output
#define DA
#define CS549 PORTD.6 // tlc549 chip select line, PD6 output
void hc164_send_byte (unsigned char byte); // 164 output subroutine
void leddisplay (void); // digital tube display subroutine
unsigned char TLC549_ADC (void); //AD conversion subroutine
unsigned char ledxs[8]={16,16,16,16,16,0,0,0}; // Digital tube display buffer
// AD conversion value hundreds, tens, and units
flash unsigned char tab[]={0xb7,0x12,0x67,0x76,0xd2,0xf4,0xf5,0x16,0xf7,0xf6,0xd7,0xf1,0xa5,0x73,0xe5,0xc5,0,0xff};
// Common cathode code 0-F, all off, all on
void main()
{
unsigned char ad_value,temp,j;
j=1;while(--j); // One cycle 11 cycles, 4M crystal oscillator, delay 2.75us
delay_ms(200);
DDRD = 0x53; // PD0, PD1 (164 driver) are set to output mode;
// PD4, PD6 (tlc549 clock and chip select) are set to output mode, PD5 (tlc549 data line) is set to input mode
while(1)
{
ad_value = TLC549_ADC(); //Read AD conversion value
temp = ad_value/100;
ledxs[5] = temp; //Get the AD conversion value hundreds digit
temp = ad_value%100;
ledxs[6] = temp/10; //Get the AD conversion value tens digit
ledxs[7] = temp%10; //Get the AD conversion value ones digit
leddisplay(); //Serial display
delay_ms(1000);
}
}
unsigned char TLC549_ADC(void)
{
unsigned char value=0;
unsigned char i,j;
CS549=1;
j=2;while(--j);
CLK549=0;
j=2;while(--j);
CS549=0; //Chip start
j=2;while(--j); //Wait for delay
for(i=0;i<8;i++) //Input sampling conversion clock (pre-sampling)
{
CLK549=1;
j=1;while(--j);
CLK549=0;
j=1;while(--j);
}
CS549=1; //Start conversion
j=10;while(--j); //Wait for conversion to end
CLK549=0;
j=2;while(--j);
CS549=0; //Start reading the conversion result
j=2;while(--j);
for(i=0;i<8;i++) // Read sample value
{
CLK549=1;
j=1;while(--j);
value<<=1;
value|=DA
CLK549=0;
j=1;while(--j);
}
CS549=1;
j=10;while(--j);
return(value); //Return the conversion result
}
void leddisplay() // Digital tube display subroutine
{
unsigned char i;
for(i=0;i<8;i++)
{
hc164_send_byte (tab[ledxs[i]]);
delay_us(2);
}
}
void hc164_send_byte (unsigned char byte) // 164 output subroutine
{
unsigned char i;
for(i=0;i<8;i++)
{
hc164_da
hc164_clk = 1;
hc164_clk = 0;
}
}
Previous article:tlc1549 CVAVR Program
Next article:DS1302 CVAVR Program
- Popular Resources
- Popular amplifiers
- A Complete Illustrated Guide to Operational Amplifier Applications (Written by Wang Zhenhong)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 51 Single Chip Microcomputer C Language Programming Classic Examples (2nd Edition) (Hou Yubao)
- Principles and Applications of Single Chip Microcomputers (Second Edition) (Wanlong)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- MCU Learning
- STM32 drives LIS25BA
- The opportunity to get a free infrared thermal imager is here! AutoNavi 2019 Temperature Measurement New Product Launch Conference
- Correct timing
- How to use the crystal oscillator and capacitor in the TaunchPad G2 kit?
- How to set the PCB wiring to 100 Ω uniform routing?
- Hello everyone, I made a microphone, and I need to use a preamplifier, I use MC2830D, the effect is average
- Tomorrow's live broadcast: The development and latest applications of sensors in industrial motors. Make an appointment now to get 2 chances to win a prize draw.
- ADI New Chinese Information (July 2019)
- STM32L151RCT6 cannot enter low power after downloading the program