I2C won't initialize properly on CH32X035

I’m trying to initialize I2C on my board, and It’s not getting past I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT), which checks the Busy, Master-Mode, and Has-Started flags. all of these flags are 0.

I have the CH32X035G8U6 board, and it does not have the A10 and A11 pins used in the WCH example. Instead, I’m mapping it to PC18 and PC19 with the 011 as the reference manual says to.


I’m also configuring the pins (C18 and C19) to GPIO_Mode_AF_PP because the reference manual says to as well.

My config looks like this. I’m calling it with (80000 , 0x02)

void IIC_Init(u32 bound, u16 address)
{
    GPIO_InitTypeDef GPIO_InitStructure = {0};
    I2C_InitTypeDef I2C_InitStructure = {0};

    // Enable AFIO first
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

    // Apply remap
    AFIO->PCFR1 &= ~(0b111 << 2);
    AFIO->PCFR1 |=  (0b011 << 2);
    
    // Enable I2C clock 
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
    
    // Enable GPIOC
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

    // Configure PC18/PC19 as AF_PP (I2C auto-OD)
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_18; // SDA
    GPIO_Init(GPIOC, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_19; // SCL
    GPIO_Init(GPIOC, &GPIO_InitStructure);

    // Now configure I2C
    I2C_InitStructure.I2C_ClockSpeed = bound;
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStructure.I2C_OwnAddress1 = address;
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;

    I2C_Init(I2C1, &I2C_InitStructure);

    // Finally enable I2C peripheral
    I2C_Cmd(I2C1, ENABLE);
}

Any debugging help or pointers to good resources would be greatly appreciated!

If you want to be an I2C master, then you additionalyl need at least

And then, do you do to this before the check event?

Even with the I2C_AcknowledgeConfig( I2C1, ENABLE );, it locks up. And yes, I check that the Busy flag is not up before calling I2C_GenerateSTART().

At this point I’m giving up and writing a bit-banging software I2C instead. I’ll post if that is succesful.