2017-02-18 02:46 AM
Hello,
i can't get my stm8s105c6t6 i2c to work. Hopefully anybody has an idea what i'm diong wrong. i'm pleased for any imput i can get.
here some changed code which doesn't do anything but i just try to measure anything on PORT E.1 &E.2. Unfortunately the two Pins remain high (i'm using the std library from stm8):
void main(void)
{ //Set Clock CLK_Config();//Set Ports
GPIO_Config();I2C_DeInit();
I2C_Init(100000, 0xA0, I2C_DUTYCYCLE_2, I2C_ACK_CURR, I2C_ADDMODE_7BIT, 16); //I2C->SR3 &=0xFD; //clear busy I2C_Cmd(ENABLE);while (1) {
I2C_GenerateSTART(ENABLE); // start I2C_Send7bitAddress(0xD0, I2C_DIRECTION_TX); // address 1101000 + 0 (WRITE) I2C_SendData(0x00); // set register pointer 00h I2C_SendData(0x00); // write 0x00 to 00h (oscillator enabled) I2C_GenerateSTOP(ENABLE); }}void CLK_Config(void)
{ CLK_DeInit(); /* Initialization of the clock */ /* Clock divider to HSI/1 */ CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); CLK_HSICmd(ENABLE);CLK_PeripheralClockConfig(CLK_PERIPHERAL_I2C,ENABLE);
}void GPIO_Config(void){ //I2C GPIO_Init(GPIOE, GPIO_PIN_1, GPIO_MODE_OUT_OD_HIZ_FAST ); GPIO_Init(GPIOE, GPIO_PIN_2, GPIO_MODE_OUT_OD_HIZ_FAST );}2017-02-18 09:17 AM
Until someone figure it out, try to use SW bit bang IO I2C.
2017-02-19 06:34 AM
Actually i hoped i could avoid doing so. But if no one got any idea what i'm doing wrong, i guess bit banging it is. Still hope dies last!
2017-02-20 12:31 AM
Here is a sample source code compatible with STM8/STM32 I2C bitbang IO. Depending on the MCU, choose the right SW NOP delay and the right way to configure the GPIOs.
2017-02-20 01:58 AM
Thanks a lot! As soon as i find time for adopting the code for the STM8S i will provide the code.
2024-11-04 02:08 AM
share me as file i can't access the file
2024-11-10 11:12 PM
Please share it with me as well. I really need it ......