传感器需要的顺序是: *Start byte *writing slaveaddr+write *读取确认 *写入要读取的寄存器地址 *读取确认 *read data.// had problem over here. No data came at RX FIFO so checked back and found that start byte is not generated. *读取确认 *stop
My current init sequence is :
SetBits16(CLK_PER_REG,I2C_ENABLE,1);//为I2C启用时钟 SetWord16(I2C_ENABLE_REG,0x0);//禁用I2C控制器 SetWord16(I2C_CON_REG,I2C_MASTER|MODE | I2C_SLAVE|DISABLE | I2C_RESTART_EN);//SLAVE is disabled SetBits16(I2C_CON_REG,I2C_SPEED,SPEED);//设置速度100 // SetBits16(I2C_CON_REG, I2C_10BITADDR_MASTER, address_mode); // Not Setting addressing mode since 7 bit SetWord16(I2C_TAR_REG,GC_OR|START | SPECIAL |(dev_address&0x3FF));//将起始位和特殊位添加到1,用于向加速计发送开始。 SetWord16(I2C_ENABLE_REG, 0x1); // Enable the I2C controller while((GetWord16(I2C\u STATUS\u REG)&0x20)!= 0 );
reading through the ADXL345 manual the following is inportant: *CS = high *如果ALT\u ADDRESS=high=>0x3A=write和0x3B=read *如果ALT\u ADDRESS=low=>0xA6=write和0xA7=read *为SDA和SCL线路的上拉电阻器使用适当的值(例如4k7) *ADXL345的ID代码=0xE5。这可以从芯片中读出,检查协议是否工作。
非常感谢你的邀请reply. I am reading the ID code of the ADXL and the start byte is not sending. I given proper pull up resistors and I am getting only the acknowledgement. Regarding the address whatever you written is 8 bit address. So I started the code by sending this 8 bit address at first (on the I2C_DATA_CMD_REG) as mentioned in the datasheet. But the problem here is - *the IC_TAR which holds only 7 bits and 10 bits addressing. So here I cannot give the 8 bit address before reading and writing. So here I given the 7 - bit addressing. Is it a problem? *In DA14580 datasheet it is mentioned that if we are writting to IC_TAR stat byte will be sent if Special(bit 11) and GC_OR_START(bit 10) is set. So after setting these the start byte interrupt should be raised. I am not getting it. This is the section - SetWord16(I2C_TAR_REG,0xC53);//activate restart- 11&10 bit set and 0x53 is the 7 bit address of the sensor.
while(GetBits16(I2C_INTR_STAT_REG,R_START_DET) == 0);// to detect the start byte has been sent or not
你好, Glad that you got the IC and working for it. I am getting the UART working properly and similarly I configured the I2C pins. I gone through the oscilloscope to get to know whether any start signal is coming (while SCL(high) SDA(low)). But came to know that it is not giving out any signals from the configured i2c pins. Whether we need to make the timings of the I2C clock to be set with values. I mean these below: SetWord16(IC_SS_SCL_LCNT,0x08); 设置字16(IC\u SS\u SCL\u HCNT,0x06);
你好,阿伦,
Q1 what sensor are you using?
Q2 did you check the periphiral I2C part within the SDK-software.
其工作方式如下:
I do not know what chip is used, but if I look to the MC3410 spec,
the following should be the case:
e、 g.通过I2C读取XOUT(见MC3410规范)。
■Start
■address (= 0x4C + R/W = 0)
■数据0x0D
■Restart
■地址(=0x4C+R/W=1)
■数据输入0(地址=0x0D)
■数据输入1(地址=0x0E)。。。通过自动增加
■Stop
现在我们要把它转换成一个工作程序:
参见用户手册UM-B-004
…//主程序的一部分
#define XOUT0 0x0D // bit 0 … 7 array[0]
#define XOUT1 0x0E//位8…15数组[1]
#define ADDRESS-IIC 0x4C // iic-address of MC3410
无符号字符数组[2];
…
i2c\ eeprom\ init(地址IIC,i2c\ U 7BIT\ U ADDR,i2c\ U 1BYTE\ U ADDR);
i2c_eeprom_read_data(array,XOUT0,2);
//数据存储在数组[0](LSB)和数组[1](MSB)中
…
我希望这是clear how it works.
Suggestions on the software (use eeprom-data-read + info in UM-B-004) were solving the issue.
嗨,谢谢你的回复。我使用adxl345作为传感器。我需要生成一个起始字节,在DA1458的数据表中提到,如果设置了SPECIAL和GC\u或\u start,写入IC\u TAR将生成一个起始字节。所以我写了这个代码:
SetWord16(I2C_TAR_REG,0xC53);//activate restart- 11&10 bit set and 0x53 is the 7 bit address of the sensor.
while(GetBits16(I2C_INTR_STAT_REG,R_START_DET) == 0);// to detect the start byte has been sent or not
但是代码被卡在上面的while部分,它无法检测到或者它没有产生一个起始字节。我连接了传感器数据表所说的一切,我只是从传感器得到确认。我还尝试了do while循环来连续触发IC_TAR,但仍然是相同的输出。
传感器需要的顺序是:
*Start byte
*writing slaveaddr+write
*读取确认
*写入要读取的寄存器地址
*读取确认
*read data.// had problem over here. No data came at RX FIFO so checked back and found that start byte is not generated.
*读取确认
*stop
My current init sequence is :
SetBits16(CLK_PER_REG,I2C_ENABLE,1);//为I2C启用时钟
SetWord16(I2C_ENABLE_REG,0x0);//禁用I2C控制器
SetWord16(I2C_CON_REG,I2C_MASTER|MODE | I2C_SLAVE|DISABLE | I2C_RESTART_EN);//SLAVE is disabled
SetBits16(I2C_CON_REG,I2C_SPEED,SPEED);//设置速度100
// SetBits16(I2C_CON_REG, I2C_10BITADDR_MASTER, address_mode); // Not Setting addressing mode since 7 bit
SetWord16(I2C_TAR_REG,GC_OR|START | SPECIAL |(dev_address&0x3FF));//将起始位和特殊位添加到1,用于向加速计发送开始。
SetWord16(I2C_ENABLE_REG, 0x1); // Enable the I2C controller
while((GetWord16(I2C\u STATUS\u REG)&0x20)!= 0 );
你能帮助我吗?
Hello Arun,
我今天会查你的信息。
Do you use any I2C-protocol-analyzer? e.g. Saleae or other brand.
那你就真的知道你的软件在工作了。
Best regards HM
Hello Arun,
reading through the ADXL345 manual the following is inportant:
*CS = high
*如果ALT\u ADDRESS=high=>0x3A=write和0x3B=read
*如果ALT\u ADDRESS=low=>0xA6=write和0xA7=read
*为SDA和SCL线路的上拉电阻器使用适当的值(例如4k7)
*ADXL345的ID代码=0xE5。这可以从芯片中读出,检查协议是否工作。
Best regards, HM
非常感谢你的邀请reply. I am reading the ID code of the ADXL and the start byte is not sending. I given proper pull up resistors and I am getting only the acknowledgement. Regarding the address whatever you written is 8 bit address. So I started the code by sending this 8 bit address at first (on the I2C_DATA_CMD_REG) as mentioned in the datasheet. But the problem here is -
*the IC_TAR which holds only 7 bits and 10 bits addressing. So here I cannot give the 8 bit address before reading and writing. So here I given the 7 - bit addressing. Is it a problem?
*In DA14580 datasheet it is mentioned that if we are writting to IC_TAR stat byte will be sent if Special(bit 11) and GC_OR_START(bit 10) is set. So after setting these the start byte interrupt should be raised. I am not getting it. This is the section -
SetWord16(I2C_TAR_REG,0xC53);//activate restart- 11&10 bit set and 0x53 is the 7 bit address of the sensor.
while(GetBits16(I2C_INTR_STAT_REG,R_START_DET) == 0);// to detect the start byte has been sent or not
Could you please let me clear about these points?
通过对DA14580的输出引脚进行初始化后将引脚作为i2c外设,发现它没有给出任何信号。请给我一个测试代码来启动I2C代码的启动条件。
Hello Arun,
have the chip (ADXL345Z) on my desc now.
See what I can do, to solve your problem.
嗯
你好,
Glad that you got the IC and working for it. I am getting the UART working properly and similarly I configured the I2C pins. I gone through the oscilloscope to get to know whether any start signal is coming (while SCL(high) SDA(low)). But came to know that it is not giving out any signals from the configured i2c pins. Whether we need to make the timings of the I2C clock to be set with values. I mean these below:
SetWord16(IC_SS_SCL_LCNT,0x08);
设置字16(IC\u SS\u SCL\u HCNT,0x06);
但是,当我运行调试器时,我发现这些行使代码重定向到hardware\u handler.c和以下部分:
if((GetWord16(SYS\u STAT\u REG)&DBG\u IS\u UP)==DBG\u IS\u UP)
__asm(“BKPT#0\n”);
Please let me know whether I need to unlock any register value to make changes to these values.
您好!
可以使用I2C EEPROM驱动程序来控制其他I2C应用芯片(非EEPROM)。温度传感器(SE95)示例如下所示。亚博国际官网平台网址
* * *步骤1。打开软件:
SDK … \peripheral_examples … DA14580_peripheral_setup.uvproj
***第二步。请参阅:periph\u setup.h:
change the HARDWARE_CONFIGURATION_INDEX (.) to ‘1’.
/*测试定义-选择与硬件设置匹配的配置
*---------------------------------------------------------
*(0) SPI FLASH MEMORY WITH UART
*(1) I2C EEPROM WITH UART
*(2)带蜂鸣器和UART的正交编码器
*---------------------------------------------------------
*/
// Hardware Configuration <0=> SPI Flash with UART <1=> I2C EEPROM with UART <2=> Quadrature Encoder, Timers & Buzzer with UART
#定义硬件配置索引(1)//1=>I2C
***step 3.
在:eeprom\u test.c(文件开头)中添加新软件
volatile int16_t temperature;
挥发性int ii;
// testing peripheral SE95 temperature sensor
// address = 1001 A2 A1 A0 R/W => 7bitaddress = 0x48 ... 0x48 + 7 = 0x4F
i2c_eeprom_init(0x48,i2c_标准,i2c_7BIT_ADDR,i2c_1BYTE_ADDR);
//读取内部ID号:
ii=i2c_eeprom_read_byte(0x05);//测试读取ID值=0xA1
// reading temperature
btrd=i2c\ eeprom\读取\数据(rd\数据,0,2);
temperature = 256 * rd_data[0] + rd_data[1];
temperature=temperature/8;//右移3位
// ***
我在加速度传感器上测试了这个软件,它成功了。
只需建立正确的连接并填写不同的7bit从机地址等。
在上面的示例中添加以下行:
i2c\ eeprom\ init(0x53,i2c\标准,i2c\ 7位\地址,i2c\ 1字节\地址);
....
btrd=i2c_eeprom_read_data(rd_data,29,29);//从addres29开始。。。地址57=29处
通过rd\ U数据[0]读取变量。。。rd\U数据[28]
I hope this make it possible for you,to read out the acceration sensor.
{hm}