Page 1 of 1

SPI 24-bit addressing

Posted: 30 Mar 2015 10:47
by jkjoy
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?

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);
}
Thanks

Re: SPI 24-bit addressing

Posted: 31 Mar 2015 09:08
by petar.timotijevic
Hi,

Please can you tell me which compiler you use?

With SPI library send data in 8-bit segments.


Just to say that Proteus simulator is not fully compatible with our compilers.


Best regards,
Peter

Re: SPI 24-bit addressing

Posted: 31 Mar 2015 10:21
by jkjoy
petar.timotijevic wrote:Hi,

Please can you tell me which compiler you use?

With SPI library send data in 8-bit segments.


Just to say that Proteus simulator is not fully compatible with our compilers.


Best regards,
Peter

I am using MikroC PRO for PIC v6.5.0

Regards

Re: SPI 24-bit addressing

Posted: 31 Mar 2015 11:08
by petar.timotijevic
Hi,

I'm asking that because you open new topic in "mikroC PRO for FT90x Wish List".


Best regards,
Peter

Re: SPI 24-bit addressing

Posted: 01 Apr 2015 04:50
by jkjoy
petar.timotijevic wrote:Hi,

I'm asking that because you open new topic in "mikroC PRO for FT90x Wish List".


Best regards,
Peter
I am sorry. Actually I cannot figure-out how it turned to be in this forum. In my understanding I posted in "mikroC PRO for PIC General".

Re: SPI 24-bit addressing

Posted: 01 Apr 2015 13:11
by petar.timotijevic
Hi,

Ok, no problem. Each specific topic should be opened in the appropriate group of topics. That maintain order and transparency in forum.


Best regards,
Peter

Re: SPI 24-bit addressing

Posted: 02 Apr 2015 05:31
by jkjoy
Thanks Peter.
Can I route this topic to "mikroC PRO for PIC General" from here?

Re: SPI 24-bit addressing

Posted: 02 Apr 2015 13:12
by petar.timotijevic
Hi,
jkjoy wrote:Thanks Peter.
Can I route this topic to "mikroC PRO for PIC General" from here?
All OK, no need for that.

With SPI library send data in 8-bit segments.


Best rgards,
Peter

Re: SPI 24-bit addressing

Posted: 06 Apr 2015 06:33
by jkjoy
OK. Thanks