你好
I2C_Send7bitAddress(I2C1 ,, I2C_Direction_Transmitter);
- >对于STM32L i2c库(保持库,请使用Cube库),7位格式的I2C_Address字节(0xA6)必须写入0x93(移位1位@右)。
这就是设备不对设备选择请求进行确认的原因。
另外,阅读你的代码,''有一个错误
发送地址字节
''代码的一部分:M24LR有2个地址字节。
为了帮助您完成程序,这是附加文件,是STM32L的I2C代码示例。
但请再次使用CUBE平台,更易于编译和使用。
最好的祝福
ST NFC客户支持
我的ANT1M24LR16E似乎没有响应我的I2C命令。
在Send7bitAddress之后,它以NACK(一个SCL时钟上的SDA为高电平)响应。这是我第一次写信。为什么它不起作用的任何想法?
以上来自于谷歌翻译
以下为原文
Hello
I2C_Send7bitAddress(I2C1, , I2C_Direction_Transmitter);
-> for STM32L i2c library (Hold library, please use Cube library), the 7bit format I2C_Address byte (0xA6 ) has to be written 0x93 (shift 1 bit @ right).
This is the reason why the device doesn't ACK to Device Select request.
In addition, reading your code, there is a mistake on ''
Send address byte
'' part of your code : the M24LR has 2 address bytes.
To help you to complete your program, this is in attached file, ,an example of I2C code for STM32L.
But again, please, uses CUBE platform, easier to compile and use.
Best regards
ST NFC customer support
My ANT1M24LR16E does not seem to repond to my I2C commands.
After the Send7bitAddress it reponds with a NACK (SDA high on one SCL clock). This is the first time I'm writing to it. Any ideas on why it is not working?
- GPIO_HIGH(GPIOD, GPIO_Pin_2);
- /* Generate start condition */
- I2C_GenerateSTART(I2C1, ENABLE);
- (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)){}
- /* Send device select+read/write cmd and wait for ACK */
- I2C_Send7bitAddress(I2C1, 0xA6, I2C_Direction_Transmitter);
- //0xA6 = 0b10100110. Page 18 datasheet
- (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)){}
- /* Send address byte. Wait until data has been received */
- I2C_SendData(I2C1, 0x00);
- (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)){}
- I2C_SendData(I2C1, 0x2A);
- (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)){}
- /* Generate Stop condition */
- I2C_GenerateSTOP(I2C1, ENABLE);
- //GPIO_LOW(GPIOD, GPIO_Pin_2);