2 posts / 0 new
Last post
yekun
Offline
Last seen: 4 months 1 week ago
Joined: 2020-04-28 12:09
DA14585 IIC 卡死

你好我在使用I2C 读取sht30时 出现了 读取函数卡死以下代码:

    WAIT_UNTIL_I2C_FIFO_IS_EMPTY();                    // Wait until Tx FIFO is empty
    WAIT_UNTIL_NO_MASTER_ACTIVITY();               // wait until no master activity 

一般是什么 情况造成的,有啥解决方法?   

 

 

i2c读取代码:

void user_i2c_multi_byte_read(uint32_t reg_address, uint8_t *rd_data, uint32_t num_bytes)
{
    user_i2c_send_address(reg_address);
      uint32_t index = 0;
      
      for(uint32_t i = 0; i < num_bytes;){
       SEND_I2C_COMMAND(0x0100 & 0x3FF); // Set R/W bit to 1 (read access) MSB
             if(!(++i % 24)){ //FIFO is 32 bits
              WAIT_UNTIL_I2C_FIFO_IS_EMPTY();                 // Wait until Tx FIFO is empty
          WAIT_UNTIL_NO_MASTER_ACTIVITY();                // wait until no master activity
                  for (uint8_t j = 0; j < 24; j++){
                        //Store the FIFO contents in ram
                        rd_data[index++] = (0xFF & GetWord16(I2C_DATA_CMD_REG)); // Get received byte
                    }
                    reg_address += 24/(i2c_cfg_env.register_width + 1);//Calculate the next register to read out 
                    user_i2c_send_address(reg_address);                //Restart the read
             }
        }
        
    WAIT_UNTIL_I2C_FIFO_IS_EMPTY(); // Wait until I2C Tx FIFO empty
    WAIT_UNTIL_NO_MASTER_ACTIVITY();
        
      while(index < num_bytes){
       rd_data[index++] = (0xFF & GetWord16(I2C_DATA_CMD_REG)); // Get received byte
        }
        
    WAIT_UNTIL_I2C_FIFO_IS_EMPTY();  // Wait until Tx FIFO is empty
    WAIT_UNTIL_NO_MASTER_ACTIVITY(); // wait until no master activity    
}
/// @} APP
 

Device: 
Martin.Ge
Offline
Last seen: 1 year 7 months ago
Staff
Joined: 2020-01-06 06:51
Hi yekun,

Hi yekun,

请问使用的是最新的SDK进行开发吗? 

关于I2C的使用,可以参考以下文档:

http://lpccs-docs.dialog-semiconductor.com/UM-B-119_DA14585-DA14531_SW_P...

Br

Martin