SPI debugging-74HC595 digital tube control experiment

Publisher:jingwenLatest update time:2017-04-04 Source: eefocusKeywords:SPI Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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!

[Repost] SPI Debugging - 74HC595 Digital Tube Control Experiment[Repost] SPI Debugging - 74HC595 Digital Tube Control Experiment

Control schematic diagram:

[Repost] SPI Debugging - 74HC595 Digital Tube Control Experiment

 

 

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

[Repost] SPI Debugging - 74HC595 Digital Tube Control Experiment

 [Repost] SPI Debugging - 74HC595 Digital Tube Control Experiment[Repost] SPI Debugging - 74HC595 Digital Tube Control Experiment


Keywords:SPI Reference address:SPI debugging-74HC595 digital tube control experiment

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

LPC1788 SPI usage
#ifndef __SPI_H_ #define __SPI_H_   #include "common.h" #include "delay.h"   // cs p1.21 //sck p1.20 //miso p1.23 //mosi p1.24   #define SPI_CLOCK   12000000   void spi0_select_cs(void);   void spi0_disSelect_cs(void);   u8 spi0_rw_data(u8 writeByte);   void spi0_set_speed(u8 speed);   void spi0_init(u8 divide);      
[Microcontroller]
Nuvoton M051 spi usage program
#include "SPI.h" #define DEBUGMSG printf STATIC UINT32 g_unSpi0Rx0Data = 0, g_unSpi1Rx0Data = 0; /**************************************** *Function name: Spi0MasterInit *Input: None *Output: None *Function: Initialize SPI0 to master mode **********************************************/ VOID Spi0MasterInit(VOID) {     
[Microcontroller]
ARM7 microcontroller (learning) - (VI), SPI interface - 01
6. SPI interface 6-(01) Introduction to SPI related applications and registers~~ 1. Features 2. Description 3. Pin description 4. Register Description a. SPI control register (SPCR—0XEOO2000)   b. SPI Status Register (SPSR —0XE0020004) c. SPI data register (SPDR - 0XE0020008) d. SPI clock c
[Microcontroller]
ARM7 microcontroller (learning) - (VI), SPI interface - 01
SPI initialization based on STM32F051 library function version
void SPI_Init(void) {   GPIO_InitTypeDef  GPIO_InitStruct;   SPI_InitTypeDef   SPI_InitStruct;   /*! SPI_CS_GPIO, SPI_MOSI_GPIO, SPI_MISO_GPIO, SPI_SCK_GPIO Init */   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF| RCC_AHBPeriph_GPIOB, ENABLE);   RCC_APB1PeriphClockCmd(FLASH_SPI2, ENABLE);    /*! Configure SPI pins: SCK */
[Microcontroller]
C51 program for microcontroller driving 74HC595
//This subroutine is for 74HC595 to send characters. This program sends the lowest bit first! //The clock pin of chip 74HC595 is pin 11 //The data pin of chip 74HC595 is pin 14 //The latch pin of chip 74HC595 is pin 12 //When multiple 74HC595s are connected in series, the signal will be latched only
[Microcontroller]
AsiaInfo Electronics launches new generation PCIe to multi-I/O (4S, 2S+1P, 2S+SPI, LB) controller
AsiaInfo Electronics launches the latest generation of "AX99100A PCIe to multi-I/O (4S, 2S+1P, 2S+SPI, LB) controller", providing a cost-effective PCIe to multi-serial and parallel I/O bridge chip solution. Through the PCI Express interface, customers can easily support multiple serial, parallel, SPI or local bus inte
[Network Communication]
AsiaInfo Electronics launches new generation PCIe to multi-I/O (4S, 2S+1P, 2S+SPI, LB) controller
Serial Design Based on SPI of AVR Microcontroller
1. SPI interface of AVR microcontroller   The SPI (Serial Peripheral INTERFACE) bus system is a synchronous serial peripheral interface that allows the MCU to communicate and exchange data with various peripheral devices in a serial manner. It is widely used in various industrial control fields. Based on this standard
[Microcontroller]
Serial Design Based on SPI of AVR Microcontroller
Note on using STM32's SPI
Today I wrote the driver for the OLED screen SSD1309, using SPI2. The screen only receives data, not sends data to the microcontroller, so only CS, SCK, and MOSI are connected in hardware, and the MISO pin of the microcontroller is not used. The chip select pin is set to software management mode, and the direction of
[Microcontroller]
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号