HC32F460JETA-LQFP48 配置IIC,PB12\PB13可以正常运行,换PA10\PA11就不行了,时钟和数据都监测不到,为啥吖?已确认PA10\PA11未被占用,且支持IIC输出,各位大佬,救救孩子
//宏定义
#define ADC_ADDRESS (0x48U) //01001000<<1 = 1001000
#define I2C_ADC_SCL_PORT (GPIO_PORT_B)
#define I2C_ADC_SCL_PIN (GPIO_PIN_12)
#define I2C_ADC_SDA_PORT (GPIO_PORT_B)
#define I2C_ADC_SDA_PIN (GPIO_PIN_13)
#define I2C_ADC_GPIO_SCL_FUNC (GPIO_FUNC_49)
#define I2C_ADC_GPIO_SDA_FUNC (GPIO_FUNC_48)
#define I2C_ADC_UNIT (CM_I2C3)
#define I2C_ADC_FCG_USE (FCG1_PERIPH_I2C3)
//初始化部分
int32_t ADC_POT_Initialize(void)
{
LL_PERIPH_WE(LL_PERIPH_ALL);
//ADC
/* Initialize I2C port*/
GPIO_SetFunc(I2C_ADC_SCL_PORT, I2C_ADC_SCL_PIN, I2C_ADC_GPIO_SCL_FUNC);
GPIO_SetFunc(I2C_ADC_SDA_PORT, I2C_ADC_SDA_PIN, I2C_ADC_GPIO_SDA_FUNC);
//GPIO_SetFunc(I2C_PTT_SCL_PORT, I2C_PTT_SCL_PIN, I2C_PTT_GPIO_SCL_FUNC);
//GPIO_SetFunc(I2C_PTT_SDA_PORT, I2C_PTT_SDA_PIN, I2C_PTT_GPIO_SDA_FUNC);
/* Enable I2C Peripheral*/
FCG_Fcg1PeriphClockCmd(I2C_ADC_FCG_USE, ENABLE);
// FCG_Fcg1PeriphClockCmd(I2C_PTT_FCG_USE, ENABLE);
int32_t i32Ret;
stc_i2c_init_t stcI2cInit;
float32_t fErr;
I2C_DeInit(I2C_ADC_UNIT);
//I2C_DeInit(I2C_PTT_UNIT);
(void)I2C_StructInit(&stcI2cInit);
stcI2cInit.u32ClockDiv = I2C_CLK_DIV8;
stcI2cInit.u32Baudrate = I2C_ADC_BAUDRATE;
stcI2cInit.u32SclTime = 3UL;
i32Ret = I2C_Init(I2C_ADC_UNIT, &stcI2cInit, &fErr);
if(i32Ret != LL_OK){
while(1);
}
/*stcI2cInit.u32Baudrate = I2C_PTT_BAUDRATE;
i32Ret = I2C_Init(I2C_PTT_UNIT, &stcI2cInit, &fErr);
if(i32Ret != LL_OK){
while(1);
}*/
I2C_BusWaitCmd(I2C_ADC_UNIT, ENABLE);
//I2C_BusWaitCmd(I2C_PTT_UNIT, ENABLE);
/* Peripheral registers write protected */
LL_PERIPH_WP(LL_PERIPH_ALL);
uint8_t data[3];
i32Ret = I2C_Master_Receive(I2C_ADC_UNIT, ADC_ADDRESS | 0x01, data, 3);
if(i32Ret == LL_OK){
memcpy(&adc_config ,&data[2], 1);
}
return i32Ret;
}
//不能正常运行的宏,我就改了针脚配置
#define ADC_ADDRESS (0x48U)
#define I2C_ADC_SCL_PORT (GPIO_PORT_A)
#define I2C_ADC_SCL_PIN (GPIO_PIN_10)
#define I2C_ADC_SDA_PORT (GPIO_PORT_A)
#define I2C_ADC_SDA_PIN (GPIO_PIN_11)
#define I2C_ADC_GPIO_SCL_FUNC (GPIO_FUNC_49)
#define I2C_ADC_GPIO_SDA_FUNC (GPIO_FUNC_48)
#define I2C_ADC_UNIT (CM_I2C1)
#define I2C_ADC_FCG_USE (FCG1_PERIPH_I2C1)
|