/*
Name: Use of 74HC595
Description: 74HC595 is an 8-bit serial input and parallel output shift register: the parallel output is a three-state output. On the rising edge of SCK, the serial data is input from SDL to the internal 8-bit shift register and output by Q7', while the parallel output is stored in the 8-bit parallel output register at the rising edge of LCK. When the control signal of the serial data input terminal OE is low enable, the output value of the parallel output terminal is equal to the value stored in the parallel output register. When OE is high, that is, the output is turned off, the parallel output terminal will remain in a high impedance state.
One thing to note here is that when the chip needs to generate a rising edge or a falling edge: in essence, it converts the corresponding pin into a high or low level. Of course, it needs to be maintained for a certain period of time as needed (you can use an empty instruction).
For specific pins and instructions, see: Baidu Baike
(https://baike.baidu.com/item/74HC595/9886491?fr=aladdin)
*/
//Send serial data to HC595
void HC595SendData(unsigned char SendVal)
{
unsigned char i;
for(i=0;i<8;i++)
{
if((SendVal<
else Out=0; // If true Out= 1
//Generate data shift signal
S_CLK=0;
//delay_ms(1);
NOP(); //Short delay to generate a pulse signal of a certain width
NOP(); // short delay
S_CLK=1;
}
//Generate data output signal
R_CLK=0; //set dataline low
//delay_ms(1);
NOP(); // short delay
NOP(); // short delay
NOP();
R_CLK=1; //
}
//IO defined in the header file
sbit Out =P3^4; //Serial data line
sbit R_CLK =P3^5; //Data parallel output control
sbit S_CLK =P3^6; //Serial clock line
#define NOP() _nop_() /* define a null instruction*/
Previous article:C51IO port simulates I2C bus driver AT24C16 (I2C protocol part)
Next article:C51 MCU serial port
Recommended ReadingLatest update time:2024-11-16 12:01
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- How to read electrical control circuit diagrams (Classic best-selling books on electronics and electrical engineering) (Zheng Fengyi)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
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
- About the problem of optocoupler screen connector
- TI dsp clock circuit selection principles
- 【LAUNCHXL-CC1350-4】- 3: Build the development environment
- [nRF52840 DK Review] +52840 NFC (Part 2)
- What domestic chips are needed to DIY a fast-charging chromium iron or an electric chromium iron that works as a laptop power supply?
- Bluetooth module communicates with mobile phone
- The compilation of the program sent by serial communication always fails
- Does the clearance below the crystal oscillator refer to the layer where the chip is located or all layers?
- [Automatic clock-in walking timing system based on face recognition] Maixbit K210 initialization loading SD card unstable problem
- How to control three colorful LED light strips with the same signal using three remote controllers