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.
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.
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.
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.
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.