What is your actual question? When you are able to read the temperature, it seems communication with the AD5933 works fine.
The data sheet for the AD5933 explains in detail how to use the freuency generator to excite the impedance, and how to calculate the impedance from the measurements.
Your view on how I2C works is not quite correct.
You should use a Restart() only when you switch from writing to slave to reading from slave (or the other way round)
Do not use Restart() after a stop condition
A complete I2C transaction runs from SendStart() to SendStop(), it is no good idea to have delays within, since that keeps the bus busy.
A delay within one I2C transaction is usually handled by the slave by extending the clock to the required time.
What are the lines
Every I2C-command except ReadByte() returns a status information which is zero (0) at normal completion. As long as your device does not run smoothly I would suggest to check every returned value and stop at the first non-zero to analyze/correct the reason.
Write a function: void I2C_Analyze(uint8 Status) , set a breakpoint when Status is non-zero and use in your program something like
and so on. This will reveal any errors instantly.
Thanks for the advice Bob! Since I need to write different values to different register addresses, instead of using Restart(), would you suggest to just use one SendStart() and then write all my values one after another to their adresses, or should I use SendStart() and SendStop() for each value?
The lines status=status<<5;
is just some bit-shifting to change the output form of my value.
I will check my code with the analyze function and will then text here again what I found out.
Best regards, Alex
this exactly is my problem, my temperature measurement is working, so I thought by just adjusting my code for the different addresses, the impedance measurement should also be fine. But somehow I am missing something.
Writing blocks of data generally is faster than a Sendstart(), WriteByte()..., SendStop() sequence. So it is up to you what is easier for you to use. Have a deep look into your AD5933 Datasheet, page 28. There reading, writing and blockread/write is explained in detail.
So finally it is working! I simply used SendStart() ......... SendStop() around every register I wanted to adress.
Thanks for the help guys
You are always welcome!