打印

VL6180x状态RESULT_INTERRUPT_STATUS_GPIO读取始终为0

[复制链接]
775|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
dianzi112|  楼主 | 2019-11-23 11:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
读取ID是OK的,如下是初始化配置VL6180X_WriteBytes(DEV_ADDR, 0x0207, 0x01);

            data_reg = VL6180x_ReadBytes(DEV_ADDR, 0x0207);//读值正确
            VL6180X_WriteBytes(DEV_ADDR, 0x0208, 0x01);
            VL6180X_WriteBytes(DEV_ADDR, 0x0096, 0x00);
            VL6180X_WriteBytes(DEV_ADDR, 0x0097, 0xFD);
            VL6180X_WriteBytes(DEV_ADDR, 0x00e3, 0x00);
            VL6180X_WriteBytes(DEV_ADDR, 0x00e4, 0x04);
            data_reg = VL6180x_ReadBytes(DEV_ADDR, 0x00e4);//读值正确


            VL6180X_WriteBytes(DEV_ADDR, 0x00e5, 0x02);
            VL6180X_WriteBytes(DEV_ADDR, 0x00e6, 0x01);
            VL6180X_WriteBytes(DEV_ADDR, 0x00e7, 0x03);
            VL6180X_WriteBytes(DEV_ADDR, 0x00f5, 0x02);
            VL6180X_WriteBytes(DEV_ADDR, 0x00d9, 0x05);
            VL6180X_WriteBytes(DEV_ADDR, 0x00db, 0xce);
            VL6180X_WriteBytes(DEV_ADDR, 0x00dc, 0x03);
            VL6180X_WriteBytes(DEV_ADDR, 0x00dd, 0xf8);
            VL6180X_WriteBytes(DEV_ADDR, 0x009f, 0x00);
            VL6180X_WriteBytes(DEV_ADDR, 0x00a3, 0x3c);
            VL6180X_WriteBytes(DEV_ADDR, 0x00b7, 0x00);
            VL6180X_WriteBytes(DEV_ADDR, 0x00bb, 0x3c);
            VL6180X_WriteBytes(DEV_ADDR, 0x00b2, 0x09);
            VL6180X_WriteBytes(DEV_ADDR, 0x00ca, 0x09);
            VL6180X_WriteBytes(DEV_ADDR, 0x0198, 0x01);
            VL6180X_WriteBytes(DEV_ADDR, 0x01b0, 0x17);
            VL6180X_WriteBytes(DEV_ADDR, 0x01ad, 0x00);
            VL6180X_WriteBytes(DEV_ADDR, 0x00ff, 0x05);
            VL6180X_WriteBytes(DEV_ADDR, 0x0100, 0x05);
            VL6180X_WriteBytes(DEV_ADDR, 0x0199, 0x05);
            VL6180X_WriteBytes(DEV_ADDR, 0x01a6, 0x1b);
            VL6180X_WriteBytes(DEV_ADDR, 0x01ac, 0x3e);
            VL6180X_WriteBytes(DEV_ADDR, 0x01a7, 0x1f);
            VL6180X_WriteBytes(DEV_ADDR, 0x0030, 0x00);
            data_reg = VL6180x_ReadBytes(DEV_ADDR, 0x0030);//读值正确
            
            // Recommended : Public registers - See data sheet for more detail
            VL6180X_WriteBytes(DEV_ADDR, 0x0011, 0x10); // Enables polling for ‘New Sample ready’when measurement completes
            VL6180X_WriteBytes(DEV_ADDR, 0x010A, 0x30);// Set the averaging sample period (compromise between lower noise and increased execution time)
            VL6180X_WriteBytes(DEV_ADDR, 0x003f, 0x46);// Sets the light and dark gain (upper nibble). Dark gain should not be changed.
            VL6180X_WriteBytes(DEV_ADDR, 0x0031, 0xFF);// sets the # of range measurements after which auto calibration of system is peRFormed
            VL6180X_WriteBytes(DEV_ADDR, 0x0040, 0x63);// Set ALS integration time to 100ms
            VL6180X_WriteBytes(DEV_ADDR, 0x002E, 0x01);// perform a single temperature calibration of the ranging sensor
            VL6180X_WriteBytes(DEV_ADDR, 0x001B, 0x09);// Set default ranging inter-measurement period to 100ms
            VL6180X_WriteBytes(DEV_ADDR, 0x003E, 0x31);// Set default ALS inter-measurement period to 500ms
            VL6180X_WriteBytes(DEV_ADDR, 0x0014, 0x24);// Configures interrupt on ‘New Sample Ready threshold event’
            data_reg = VL6180x_ReadBytes(DEV_ADDR, 0x0014);//读值正确
            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_FRESH_OUT_OF_RESET, 0x00);
如下是读取距离的值,RESULT_INTERRUPT_STATUS_GPIO始终为0,,RESULT_RANGE_STATUS的值为0x01,VL6180X_SYSRANGE_START写入为0x01,读取为0
uint8_t RangePollingRead(void)
{
    uint8_t status;
    uint8_t distance;

    /* Wait for device ready. */
    do {
        status = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_RANGE_STATUS);
    } while ((status & (1 << 0)) == 0);

    VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_START, START_SINGLE_MODE);
    data_reg = VL6180x_ReadBytes(DEV_ADDR, VL6180X_SYSRANGE_START);

    /*status = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_INTERRUPT_STATUS_GPIO);
    status = status & RANGE_SINGLE_MODE_MASK;*/
    status = 0;
     /* Wait for measurement ready. */
    while (status != RANGE_SINGLE_MODE_READY) {
       status = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_INTERRUPT_STATUS_GPIO);
        status = status & RANGE_SINGLE_MODE_MASK;
        __delay_ms(1);
    }
    __delay_ms(10);
    distance = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_RANGE_VAL);
    VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_INTERRUPT_CLEAR, CLEAR_RANGE_INT);
    return distance;
}


求大神帮忙看下有哪里错了吗,卡了很久了。。。

使用特权

评论回复

相关帖子

沙发
dianzi112|  楼主 | 2019-11-25 08:12 | 只看该作者

使用特权

评论回复
板凳
just_2010| | 2023-10-13 14:31 | 只看该作者
问问楼主后面如何解决的,我现在卡主了,也是这个问题

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

13

帖子

0

粉丝