Use of 74HC595 in C51

Publisher:bianzitong521Latest update time:2018-07-21 Source: eefocusKeywords:C51  74HC595 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/* 

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*/


Keywords:C51  74HC595 Reference address:Use of 74HC595 in C51

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

C51 MCU Study Notes Serial Communication
Introduction Serial communication is a communication method between the microcontroller and the PC. Communication mode: parallel, serial, synchronous, asynchronous (most commonly used) Transmission direction: simplex, half-duplex (different time), full-duplex basic structure Related registers SCON serial por
[Microcontroller]
C51 MCU Study Notes Serial Communication
Interface program between clock chip DS1302 and MCS51 microcontroller C51
#pragma small #include #include /******************************************** * DS1302  PIN  Configuration * ******************************************** sbit DS_CLK = P1^6 sbit DS_IO = P1^5; sbit DS_RST = P1^4; /******************************************** * Shift Data from Mcu in DS1302 * ************************
[Microcontroller]
Learn the basics of C51 5 "Operators"
5. Operators      Turbo C has a wide range of operators, which can be divided into three categories: arithmetic operators, relational and logical operators, and bitwise operators. In addition, there are some operators used to complete special tasks. They are introduced below.      5.1 Arithmetic Operators     
[Microcontroller]
C51 memset
I was looking at the 51 program just now and found a function memset(). I have rarely seen it before, so I wrote it down here.   This is a screenshot of the explanation of memset found by F1   This function is included in the string.h header file. Its function is to copy a character of a specified length into a
[Microcontroller]
C51 memset
24c02 reading and writing program written by c51
#include  reg51.h // 对24C02的读、写 // extern void DelayMs(unsigned int); // extern void Read24c02(unsigned char *RamAddress,unsigned char RomAddress,unsigned char bytes); // extern void Write24c02(unsigned char *RamAddress,unsigned char RomAddress,unsigned char bytes); /**************************************************
[Microcontroller]
Key recognition principle diagram based on C51 single chip microcomputer
  Each time switch SP1 is pressed, the count value increases by 1, and its binary count value is displayed through P1.0 to P1.3 of the P1 port of the AT89S51 microcontroller.   (1. Connect the P3.7/RD port in the "MCU System" area to the SP1 port in the "Standalone Keyboard" area;   (2. Use 8-core cable to connect
[Microcontroller]
Key recognition principle diagram based on C51 single chip microcomputer
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号