-
GD32F的IIC模块读取是,读的字节数为2,将I2C_CTL0的POAP置为1?
GD32F103的IIC模块在进行eeprom读取的时候,当读取的字节数为2时,需要将I2C_CTL0的POAP置为1;POAP的定义如下:0:ACKEN位决定对当前正在接收的字节发送ACK;1:ACKEN位决定是否对下一个字节发送ACK.我的理解时:当读取的字节数为2时,该位置1,表示接收第一个字节后,发送ACK;接收第二个字节后,不发送ACK。这样就能保证时序的正确性。不知道各位大佬是如何理解的,请赐教。谢谢!代码如下:voideeprom_buffer_read(uint8_t*p_buffer,uint8_tread_address,uint16_tnumber_of_byte){/*waituntilI2Cbusisidle*/while(i2c_flag_get(I2C0,I2C_FLAG_I2CBSY));if(2==number_of_byte){i2c_ackpos_config(I2C0,I2C_ACKPOS_NEXT);//如果接收的的字节数等于2,则将将I2C_CTL0的POAP置为1。}/*sendastartconditiontoI2Cbus*/i2c_start_on_bus(I2C0);/*waituntilSBSENDbitisset*/while(!i2c_flag_get(I2C0,I2C_FLAG_SBSEND));/*sendslaveaddresstoI2Cbus*/i2c_master_addressing(I2C0,eeprom_address,I2C_TRANSMITTER);/*waituntilADDSENDbitisset*/while(!i2c_flag_get(I2C0,I2C_FLAG_ADDSEND));/*cleartheADDSENDbit*/i2c_flag_clear(I2C0,I2C_FLAG_ADDSEND);/*waituntilthetransmitdatabufferisempty*/while(SET!=i2c_flag_get(I2C0,I2C_FLAG_TBE));/*enableI2C0*/i2c_enable(I2C0);/*sendtheEEPROM'sinternaladdresstowriteto*/i2c_data_transmit(I2C0,read_address);/*waituntilBTCbitisset*/while(!i2c_flag_get(I2C0,I2C_FLAG_BTC));/*sendastartconditiontoI2Cbus*/i2c_start_on_bus(I2C0);/*waituntilSBSENDbitisset*/while(!i2c_flag_get(I2C0,I2C_FLAG_SBSEND));/*sendslaveaddresstoI2Cbus*/i2c_master_addressing(I2C0,eeprom_address,I2C_RECEIVER);if(number_of_byte<3){/*disableacknowledge*/i2c_ack_config(I2C0,I2C_ACK_DISABLE);}/*waituntilADDSENDbitisset*/while(!i2c_flag_get(I2C0,I2C_FLAG_ADDSEND));/*cle
2021-01-08 2