SPI 24-bit addressing
Posted: 30 Mar 2015 10:47
I am communicating with an SPI Audio record IC which has 24-bit address and 16-bit offset. I made a structure to read/write data from that device which has,
Command - 1 byte Address - 3 byte (24-bit) Offset address - 2 byte (16-bit)
During simulation (in proteous), it is found that 4th byte (MSB of address) is overlapped by 5th byte (LSB of Offset).
Following is the code. Please help what are the changes I need to do in the code. Is the bit field operation for 16 or 24 bits ok?
Thanks
Command - 1 byte Address - 3 byte (24-bit) Offset address - 2 byte (16-bit)
During simulation (in proteous), it is found that 4th byte (MSB of address) is overlapped by 5th byte (LSB of Offset).
Following is the code. Please help what are the changes I need to do in the code. Is the bit field operation for 16 or 24 bits ok?
Code: Select all
typedef struct {
unsigned char Command:8 ;
unsigned long Addr:24;
unsigned int Offset:16;
} ISD_Struct;
ISD_Struct ISD_Rec;
void main()
{
address = 0x563412 ;
OFFST = 0x9A78 ;
ISD_Rec.Command = 0xBC;
ISD_Rec.Addr = address;
ISD_Rec.Offset = OFFST;
Write_SPI(&ISD_Rec,6); //sending (1byte command + 3byte address + 2 byte offset)
//Delay_ms(1000);
}