io模拟spi时序(IO simulation SPI timing)
io模拟spi时序(IO simulation SPI timing)
Module: IO accumulation simulation SPI timing 18:21:09| classification: 2011-05-19 embedded development | Tags: | report | font
in
Small subscription
Motorola SPI is proposed a bus structure, than PHILPS proposed IIC bus more than two lines, these two kinds of bus structure because they occupy the IO port and has been widely used, in general, SPI bus and IIC bus are simulated by IO, there are a considerable number of integrated chip IIC and SPI, such as STC12C60S2 in integrated SPI interface. Let's use analog SPI to communicate!!!!
Program from a simulation forum inside, mainly want to accumulate a SPI driver, and to understand how to write programs based on the chip timing diagram. Of course, you can practice English, because the damn data manuals are all in english!!!!
/*********************************************************************************************
Program name:
Author: Li Cong
Writing time: 20 days
Hardware support:
Interface description:
Edit log:
NO.1-
/*********************************************************************************************
Description: a complete simulation of SPI interface design, 25AA020AEEPROM microcontroller and microchip company communicate with SPI interface
From the timing diagram: when writing a byte, write permission, write instructions, write the address, and then write data, and then determine whether the data is transmitted.
When you read a byte, write the instruction first, then write the address, and then you can read the byte.
/*********************************************************************************************/
#include
#include
#define uchar unsigned char
#define uint unsigned int
/*********************************************************************************************/
Sbit SCK=P2^0; / / clock
Sbit SI=P2^2; / / SCM input interface chip SO, so as to input
Sbit SO=P2^1; / / MCU output interface chip SI
Sbit CS=P2^3; / / enable connection c