Hello IgorSK,
Ya, thanks for your advice. I just found one useful method to test their replies. Simon have wrote a useful test program to check the exist of I2C devices. I2CU
The I2CU program checkup is 0x7E address. This address is working for me is we put fix/const value.
....
if (0 == write(0x55)) {
...
...
write(0xAA);
wait(0.2);
..
.
The output LED is blinking ON and OFF.
If i put something variable value then my output LED will always stay ON.
....
if (0 == write(i)) {
...
...
i++;
wait(0.2);
..
.
P/s: may i know how to put the text to next line? I still can't type my sentence to next line when i do post reply. Is it every sentence we must put a '.'+'enter' then only can go to next line? :(
Dear All,
I'm using this sample code to do some modification.
The problem that i facing is when i write a variable value to PCF8574 it is not working. It just work for const. value which is like sample code.
Following coding is what i trying to test.
#include "mbed.h" I2C i2c(p9,p10); DigitalOut led1(LED1); const int addr = 0x7E; // define the (8-bit) I2C Address for the PC int write(char byteOut) { char * cmd = new char[1]; cmd[0] = byteOut; return i2c.write(addr, cmd, 1); } int main() { char i=0; i2c.frequency(100000); while (1) { /* now flash on-bosrd LED1 if the write to I2C works This confirms that you've got the right address and that you remembered the pull-up resistors on SCL/SDA :) */ if (0 == write(i)) { led1 = 1; wait(0.2); led1 = 0; } i++; printf("i = %d\n\r", i); wait(0.2); } }Is it the coding problem or compiler issue?
Thank you...