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.

mastergetsi2c, I2C_data_wait parameter

Status
Not open for further replies.
this is the function :
unsigned int MastergetsI2C(unsigned int length, unsigned char *rdptr, unsigned int i2c_data_wait);

explanation:
i2c_data_wait - This is the time-out count for which the module has to wait before return. If the time-out count is ‘N’, the actual time out would be about (20 * N – 1) instruction cycles.

i couldnt understand, how to measure i2c_data_wait parameter, i dont know what to write for it.
 

First calculate how much time the processor takes for executing 1 instruction.

Normally it will be in microcseconds....You write the value of 'N' in such a way that it should wait for few mSecs...say for example, 10 or 20 mS.

Also check in the datasheet if there is any time limit is specified before using this function.

For example, you had sent a command to the masterI2C and the datasheet specified that you to need to wait 30mS then calculate the value of N accordingly.

You know what command has been sent to the master I2C device..And the datasheet will give you a clear picture for one command what will be the response obtained along wit the length...

So the function will be looking like something below....

//Declaration globally or private

unsigned int glGetlen=0;
unsigned char *ptrGetdata;

#define I2CWAIT 30

unsigned int MastergetsI2C(glGetlen, *ptrGetdata, I2CWAIT); //use this function like this...30 is for example written...

once the control comes out of this, you can validate the data....
 

thanks a lot for your answer,
some points i didnt understand

why did you write glGetlen=0; it defines, how many byte will we get from slave.
 

Its just declaration plus initialization..

Once you call the function unsigned int MastergetsI2C(glGetlen, *ptrGetdata, I2CWAIT), if there is any data to be received from the mastergetsi2c, then the glGetlen will be the size of the data that is being read..

So the value of 0 will be over written to the length of the data that has been received from the master...
 

So the value of 0 will be over written to the length of the data that has been received from the master...
Can hardly happen for a parameter specified by value...
Getlen does not return the actual read length, it specifies the data length to be read.
 

@FvM,

I m sorry..if that is the case then gblGetLen can be initialised to some other value like 30 or 50...

Thanks for pointing out the mistake..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top