Hello everyone,
When I use the example program for I2C located in <install_dir>\Freescale\Freescale_MQX_4_1\mqx\examples\i2c,I found the program stop at "result = fwrite (mem, 1, 1, fd);"
The E2PROM type is 24C02.
mem[0] = (uint8_t)addr;
printf (" Write to address 0x%02x ... ", mem[0]);
do
{
result = fwrite (mem, 1, 1, fd);
printf("\r\n Hello World \r\n");
} while (result < 1)
Need help,thks!
Solved! Go to Solution.
Hello every one ,
I have made a mistake,the I2C device address in MQX should be below format:
for example, AT24C02, addr = 1 0 1 0 A2 A1 A0 R/W,this should be shift right one bit (addr>>1),then this parameter pass to MQX I2C driver .
Thks !
Best Regards!
Hello every one ,
I have made a mistake,the I2C device address in MQX should be below format:
for example, AT24C02, addr = 1 0 1 0 A2 A1 A0 R/W,this should be shift right one bit (addr>>1),then this parameter pass to MQX I2C driver .
Thks !
Best Regards!
I see problems that the driver hangs.
I think it's easiest to modify the polled version.
The drivers in MQX are no specific stable or well written.
Best regards Poul-Erik.
.
Thks for your reply,
so what should I do for this problem?
before that, I test the I2C driver for ACCELEROMETER, the program run normally.
after that I test the program for my specific E2PROM,I ran into problems.
Best regard
What we have seen is long time stability problems. We use a 24C128 + some IO port expanders, and it works most of the time. I You can't get it working for the first time, You shod use a logic analyzer or a osciloscop.
Best regards.
Hello,Poul-Erik.
Can you offer me the E2PROM Demo code?
Thks!
Best Regards!
Just now,I test the program for at24c02 and find that " I2C start, send address and get ack ... OK ... ack ==1".
The ACK ought to be '0',now I get ACK=1, I think this is the problem here.
Hello Tong,
Yes you are right, please check the below thread.
[MQX 4.1]I2C demo for MMA8451Q
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello,soledad.
I have seen the code for ACCELEROMETER and used for TWR_K70F120M,the program run normally,when I use it for E2PROM,there is NACK for sending slave device address byte.
I use external E2PROM connected to TWR_K70F120M's I2C0 channel for testing,I don't know why this happen.
Thks!
Best Regard!