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.

help with 16 bit manipulation

Status
Not open for further replies.

kbbhushan

Junior Member level 1
Joined
Mar 29, 2008
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,411
manipuler 24 bits spi

Hi,
I am communicating atmega32 with ade7753 through spi. atmega32 as master and ade7753 as slave. I need to read 16/24 bit registers from ade7753. But only 8 bits are transmitted once.
How should I read 16/24 bits through spi.
Please someone help me regarding this.

Thanks in advance.
 

You need to continue clocking the ADE7753 after the command byte so keep on writing as many dummy bytes as needed.
The chip will ignore Din after the command byte.

See figure 94 on page 50 in the datasheet.

/Ram
 

Hi,
Thanks for helping me.
Thats not my projblem. Once I receive two or three bytes after transmitting dummy values, how can I append them to get one value which is needed.

Thank You.
 

Ahh, I see.
In your program you can declare a union of four chars and one long.
Then when the bytes come you store them to the chars one by one and then you can read the value as one long.

Something like this:

Code:
typedef union TLong			// Defines the type TLong to be a union of a 32-bit long and four 8-bit chars.
{	                 		
	long Long;	
	char Char[4];			
} TLong;

TLong value;

// Assuming that your compiler uses big endian.
value.Char[3]	= 0x00;
value.Char[2]	= SPIDATA;	// The first byte is the most significant	
value.Char[1]	= SPIDATA;
value.Char[0]	= SPIDATA;	// The last byte is the least significant	

value.Long <-- Your 24-bit value in a 32-bit long.

/Ram

PS The same goes for a 16-bit value - declare a union of one int and two chars.
 

    kbbhushan

    Points: 2
    Helpful Answer Positive Rating
Hi,

Thankyou very much.

Please if you don't mind, I had posted another doubt in the Microcontrollers forum under the topic "help with ade7753",here is the link
#1053020
My spi communication module is not working. Can you please check that and correct me.

Thanks in advance.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top