-
GD32 F4硬件I2C总是锁死
1.问题描述买了一个磁力计模块,用杜邦线连接到427start开发板,参考网上各种例程一直失败,要么是ADSEND不置1,要么是I2C总线一直忙,反复置位或者上电重启能读到一次,今天尝试了参考官方EEPROM的延时检测程序,还是没办法实现,求解求解!!2.代码代码1:未加延时检测代码while(i2c_flag_get(I2C1,I2C_FLAG_I2CBSY));printf("I2Cbusisidle\r\n");i2c_start_on_bus(I2C1);while(!i2c_flag_get(I2C1,I2C_FLAG_SBSEND));printf("SBSENDbitisset\r\n");i2c_master_addressing(I2C1,QMC5883L_DEFAULT_ADDRESS,I2C_RECEIVER);while(!i2c_flag_get(I2C1,I2C_FLAG_ADDSEND));printf("ADDSENDbitisset\r\n");i2c_flag_clear(I2C1,I2C_FLAG_ADDSEND);i2c_ack_config(I2C1,I2C_ACK_DISABLE);i2c_stop_on_bus(I2C1);while(!i2c_flag_get(I2C1,I2C_FLAG_RBNE));printf("I2C_FLAG_RBNEbitisset\r\n");chipID=i2c_data_receive(I2C1);printf("0x%u\r\n",chipID);++++++++++++++++++++++++++++++++++++++++++++++++代码2延时检测/*!\filemain.c\briefGPIOrunningleddemo\version2022-04-26,V2.0.0,demoforGD32F4xx*//*Copyright(c)2022,GigaDeviceSemiconductorInc.Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,arepermittedprovidedthatthefollowingconditionsaremet:1.Redistributionsofsourcecodemustretaintheabovecopyrightnotice,thislistofconditionsandthefollowingdisclaimer.2.Redistributionsinbinaryformmustreproducetheabovecopyrightnotice,thislistofconditionsandthefollowingdisclaimerinthedocumentationand/orothermaterialsprovidedwiththedistribution.3.Neitherthenameofthecopyrightholdernorthenamesofitscontributorsmaybeusedtoendorseorpromoteproductsderivedfromthissoftwarewithoutspecificpriorwrittenpermission.THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTO
2022-10-22 9