Question on i2c-library, reading multiple bytes

General discussion on mikroBasic PRO for ARM.
Post Reply
Author
Message
Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Question on i2c-library, reading multiple bytes

#1 Post by Thomas.Pahl@t-online.de » 17 Jul 2021 11:26

i2c library help says:
[code]I2C1_Read(0x50, data_, num_bytes, END_MODE_STOP) [/code]
when i read one single byte (num_bytes = 1 and data_ is a byte variable) - no problem.
when i read multiple bytes (num_bytes =8 where are they written to? if data_ is a byte array it does not write to the elements but only to the first.
Is there a location where the library writes to? Is there an autoincrement of what?
thanks

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Question on i2c-library, reading multiple bytes

#2 Post by filip » 21 Jul 2021 08:48

Hi,

Yes, there is an autoincrement in the library that handles this, you can put the data into an array, like this :

Code: Select all

char read_data[28];

data_[0] = address;
I2C1_Start();              // issue I2C start signal
I2C1_Write(0x50,data_,1,END_MODE_RESTART);
I2C1_Read(0x50,read_data,number_fo_bytes_to_read,END_MODE_STOP);
Regards,
Filip.

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: Question on i2c-library, reading multiple bytes

#3 Post by Thomas.Pahl@t-online.de » 21 Jul 2021 15:25

Does not exactly look like basic :D
But i asked for the principle. That is clear. Will test it.

Thanks again.

Post Reply

Return to “mikroBasic PRO for ARM General”