Other Parts Discussed in Thread: C2000WARE
在使用sysconfig v1.21工具进行I2C配置时,不勾选Default I2C Module Clock Frequency选项,生成的代码会调用I2C_initControllerModuleFrequency函数,此时生成的代码在代用该函数后缺少";",导致编译报错。
自动生成的代码如下,注意标红行末尾缺少分号:
void I2C_EEPROM_init(){
I2C_disableModule(I2C_EEPROM_BASE);
I2C_initControllerModuleFrequency(I2C_EEPROM_BASE, DEVICE_SYSCLK_FREQ, I2C_EEPROM_BITRATE, I2C_DUTYCYCLE_33, I2C_EEPROM_MODULE_CLOCK_FREQUENCY)
I2C_setConfig(I2C_EEPROM_BASE, I2C_CONTROLLER_SEND_MODE);
I2C_disableLoopback(I2C_EEPROM_BASE);
I2C_setOwnAddress(I2C_EEPROM_BASE, I2C_EEPROM_OWN_ADDRESS);
I2C_setTargetAddress(I2C_EEPROM_BASE, I2C_EEPROM_TARGET_ADDRESS);
I2C_setBitCount(I2C_EEPROM_BASE, I2C_BITCOUNT_8);
I2C_setDataCount(I2C_EEPROM_BASE, 1);
I2C_setAddressMode(I2C_EEPROM_BASE, I2C_ADDR_MODE_7BITS);
I2C_disableFIFO(I2C_EEPROM_BASE);
I2C_setEmulationMode(I2C_EEPROM_BASE, I2C_EMULATION_FREE_RUN);
I2C_enableModule(I2C_EEPROM_BASE);
}