Note: To use the SPI of S3C2440 to control peripherals, you must connect a pull-up resistor to nSSn to ensure normal data transmission. You can find another I/0 port to control the chip select of 74HC595.
74HC595 is an 8-bit serial input to parallel output shift register. 74HC595 pin diagram!
Control schematic diagram:
RCK is also known as STCP. Before collecting data, RCK should be given a low level, and after collecting the signal, it should be given a high level.
RCK (pin 12): The data of the shift register enters the data storage register at the rising edge, and the data of the storage register remains unchanged at the falling edge. I usually set RCK to a low level. When the shift is completed, a positive pulse (at 5V, more than a few tens of nanoseconds is enough. I usually choose microseconds) is generated at the RCK end to update the displayed data.
Control Chart Procedure:
void SPI_TEST(void)
{
int i;
U32 k;
Uart_Printf("SPI COMMNICATIONn");
Uart_Printf("SPI0 is master ,SPI1 is slave!n");
SPI_Init();
rGPBCON = 0x15400;
while(1)
{
for( i=0;i<19;i++)
{
rGPBDAT=0x00;
while(!(rSPSTA0&0x01));
rSPTDAT0=data[i];
delay(1000);
rGPBDAT=0xFF;
delay(1000);
}
}
Uart_Printf("nthat's ok!n");
}
void SPI_Init(void)
{
rGPECON=(2<<26)|(2<<24)|(2<<22) ;
rGPGCON=(3<<14)|(3<<12)|(3<<10)|(3<<6)|(1<<4);
rGPGUP&=0xFF13;
rGPEUP&=0xC7FF;
rSPPRE0=PCLK/ 2/ucSpiBaud-1;
rSPCON0=(0<<5)|(1<<4)|(1<<3)|(0<<2)|(0<<1)|(0<<0);
rSPPRE1=PCLK/2/ucSpiBaud-1;
rSPCON1=(0<<5)|(1<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0);
rSPPIN0=(0<< 2)|(1<<1)|(0<<0);
rGPGDAT&=0xFFFB;
}
void delay(U32 dly)
{
U32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
At the same time, the data transferred out by 74HC595 can be read by SPI
while(!(rSPSTA0&0x01));
k= rSPRDAT1;
Uart_Printf("RX %xn",k);
Enter the picture
Previous article:Cortex entry stm32 water lamp experiment_program interpretation
Next article:STM32 DS18B20 driver transplantation
Recommended ReadingLatest update time:2024-11-16 14:48
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Digilent Vivado library
- Teach you to learn 51 single chip microcomputer-C language version (Second Edition) (Song Xuefeng)
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
- Latest MicroPython firmware for nRF52840D
- EEWORLD University Hall----Consumer Electronics Application and Design Seminar
- Please tell me the value of this color code diode
- 28335 Transmit control signals between control boards
- Keyboard Man Terminator: Automatic Counterattack Keyboard
- MSP430G2755 Main Bootloader UART Porting Guide
- Hyperlink Architecture in TMS320C6678
- How does a microcontroller collect analog signals through an ADC module?
- Small wireless charging electronic circuit design
- Standard amplifier functions in HEV/EV battery management systems