打印

GD32F1x0的 i2c问题

[复制链接]
1267|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
tincal|  楼主 | 2022-3-27 14:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
板子使用 单片机GD32F130
然后使用GD32F1x0_Firmware_Library_v3.1.0里面的例程Examples\I2C\Slave_receiver
main函数代码如下
int main(void)
{
    int i;

    /* RCU config */
    rcu_config();
    /* GPIO config */
    gpio_config();
    /* I2C config */
    i2c_config();

    i=0;
    /* wait until ADDSEND bit is set */
    while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_ADDSEND));
    /* clear ADDSEND bit */
    i2c_flag_clear(BOARD_I2C, I2C_FLAG_ADDSEND);
    for(i=0; i<16; i++){
        /* wait until the RBNE bit is set */
        while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_RBNE));

        /* read a data byte from I2C_DATA */
        i2c_receiver = i2c_data_receive(BOARD_I2C);
    }
    /* wait until the STPDET bit is set */
    while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_STPDET));
    /* clear the STPDET bit */
    i2c_enable(BOARD_I2C);

    while(1){
    }
}

然后用主机却探测不到 该从机,请问哪里还需要修改的,谢谢





使用特权

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

本版积分规则

4

主题

5

帖子

0

粉丝