04-22-2024 05:53 AM - edited 04-22-2024 05:58 AM
Hello,
I'm currently working with NI USB-8451 in order to communicate with I2C target (TCA6408ARGTR). I'm working with CVI labwindows. I'm new to I2C so i'm struggling a bit.
In the TCA6408ARGTR's datasheet, I've found that the address is 0x20 and there are 4 registers. I want to control the output P4 and P5, so I assume that I have to send 0011 0000 to register 1 and 1100 1111 to register 3 as per the datasheet.
So first, I've watched the different examples in CVI and I've tried to replicate the logic:
I've tried with the I2C script write example but nothing work. I think I have the right address since I don't have any errors, so I assume that the 8451 receives an ACK from the target.
I would be happy if someone can help me.
Edit: I forgot to say that I have a 10k pull up resistor for each SDA and SCL line
Solved! Go to Solution.
04-23-2024 02:38 AM - edited 04-23-2024 02:48 AM
You most likely want to change this:
ni845xI2cScriptOpen(&scriptHandle);
ni845xI2cScriptClockRate(scriptHandle,100);
ni845xI2cScriptIssueStart(scriptHandle);
ni845xI2cScriptAddressWrite(scriptHandle, (uInt8)(0x20 & 0x7F));
// ni845xI2cScriptWrite(scriptHandle,sizeof(buffer[0]),&buffer[0]);
// ni845xI2cScriptWrite(scriptHandle,sizeof(buffer[1]),&buffer[1]);
ni845xI2cScriptWrite(scriptHandle,2,&buffer[0]);
ni845xI2cScriptIssueStop(scriptHandle);
ni845xI2cScriptRun(scriptHandle, deviceHandle, 0);
ni845xI2cScriptClose(scriptHandle);
The main reason being that you want to have the two bytes transferred as one I2C transaction and not two!
But why are you even using the script API? It would be easier to simply use the Basic API.
04-23-2024 03:09 AM
Hello,
Thanks for your answer. I worked a bit on it yesterday, and apparently the I2C is not the issue. In fact, I was thinking that the I2C was not working because I'm new to it, and it was a simpler solution to say that I was at fault instead of the PCB.
But after some test, I figure that the output changes correctly when I send an I2C command. So my script was not the problem, I just panicked for nothing.
I used the script API, but I've also tried the basic API with the same outcome.
Anyway, thanks for your time.