Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

3 wire - Serial data transfer (Read/Write)

Status
Not open for further replies.

Maverickmax

Advanced Member level 1
Joined
Dec 6, 2004
Messages
404
Helped
8
Reputation
16
Reaction score
3
Trophy points
1,298
Activity points
3,689
Hello

It is my first time to use 3 wire - serial communication and I intend to learn. So far I understand how to write but I am not 100 percent sure about reading the serial data from the device. Thus Do you have C code example that read the data in serial transfer?

Maverick Max
 

Serial data transfer , can be done synchronous or asynchronous . On asynchronous .You only need 2 wires + (soft or hardware protocol).On synchronous .there are several formats
two wires + protocol = I2C or 4 wires without protocol = SPI .As well as others
Which one is the one you are talking about ??
 

Well Im using three wire serial eeprom such as AT93C46 as it consists of Data In, Data Out, SK and CS.

So I think that I need to create algorithm that transfer data serially in order to write or read the device.

Do you know what I mean?

Maverick Max
 

Yes, I am using 4 wire without protocol (Serial Peripheral Interface) for my serial eeprom but I am not sure about reading process.

after transmitting the address bits, should I use the serial clock (off and on) in order to get 1 bit from the Data Out Pin?

can you please provide a sample code in C?

Maverick Max
 

If you just want to read a databyte from an SPI device you must write one (dummy) databyte for every databyte you want to read.

SPI reads and writes at the same time as there are seperate datalines for IN and OUT.

See my small C example (for Microchip PIC) below.
Code:
	do
	{
		SSPBUF=0x00;				//	write	dummy	value	to	start	register	shift

		while(!STAT_BF)
			WATCHDOG();				//	wait until data has been received via SPI

		*buffer_adresse=SSPBUF;	//	store data
		buffer_adresse++;
	}
	while(--buffer_counter);	// until a complete block has been read


hope this helps
 

Ok, if is it ok to create my own serial clock function prototype in order to generate pulse after transmitting each data bit?

Is that asychronous protocol?

Maverick Max
 

Look for example here for a small explanation of the SPI bus:
https://www.phanderson.com/picaxe/spi.html

You have two options:

1) if your micro has spi hardware built in I would use this

2) you can create SPI via "bit banging"

best regards
 

I have checked the link out as you gave me. AT89C51 doesn't has MOSI or MISO. Hence I has to implement bit-banging algorithm. Is that correct?

Maverick Max
 

you can find source code of 3-wire serial at atmel website
good lucks.
 


Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top