初始化:mcpwm
Code: Select all
mcpwm_init(MCPWM_UNIT_0, MCPWM_TIMER_1, &pwm_config); //附件内第606行
Code: Select all
i2c_param_config(671): i2c clock choice is invalid, please check flag and frequency
Code: Select all
void app_main()
{
static const char *TAG = "i2c-example";
// 配置I2C从机
i2c_config_t conf_slave;
conf_slave.mode = I2C_MODE_SLAVE;
conf_slave.sda_io_num = I2C_SLAVE_SDA_GPIO;
conf_slave.scl_io_num = I2C_SLAVE_SCL_GPIO;
conf_slave.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf_slave.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf_slave.slave.addr_10bit_en = 0;
conf_slave.slave.slave_addr = I2C_SLAVE_ADDRESS;
i2c_param_config(I2C_NUM_0, &conf_slave);
//接受数据部分
int res[22] = {};
while (1) {
// 从I2C总线读取数据
ESP_LOGI(TAG,"loading");
uint8_t data[64];
int len = i2c_slave_read_buffer(I2C_NUM_0, data, sizeof(data), 200 / portTICK_RATE_MS);
if (len > 0 &&data[1]==255) {
//清除寄存器内的数据和res的数据
for(int i=1;i<21;i++){
res[i] = 0;
}
continue;
}
else if (len>0&&data[1]==254) {
motor_capture();
}
else if (len>0) {
for(int i=1;i<21;i++){
res[i] = data[i];
}
break;
}
}
附件中删除606和640行就能顺利运行,mcpwm和i2c部分单独使用没问题。引脚的使用没有重复。求大佬帮忙看看啥问题。