cancel
Showing results for 
Search instead for 
Did you mean: 

stm8s208cb(Slave) and stm8s105c6t6(Master) I2C Communication

erhan
Associate
Posted on February 05, 2016 at 14:24

Hello,

I want to use I2C communication between stm8s208cb(slave) and stm8s105c6t6(master). I use stm8s standard peripheral library.

stm8s105c6t6(master) code:

-in the void main

CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); //16MHz clock

I2C_Init(400000, 0xA0, I2C_DUTYCYCLE_2, I2C_ACK_CURR, I2C_ADDMODE_7BIT, 16); //i2c init

I2C_Cmd(ENABLE);

I2C_GenerateSTART(ENABLE); //send start condition

I2C_Send7bitAddress(0x30, I2C_DIRECTION_TX); //send slave address for write

/********************************************************************/

-in the while(1)

I2C_GenerateSTART(ENABLE);

I2C_SendData(0x61);

I2C_GenerateSTOP(ENABLE);

stm8s208cb(slave) code:

-in the void main

CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); //16MHz System Clock

I2C_DeInit();

I2C_Init(400000, 0x30, I2C_DUTYCYCLE_2, I2C_ACK_CURR, I2C_ADDMODE_7BIT, 16);

I2C_Cmd(ENABLE);

-in the while(1)

uint8_t RxBuffer = I2C_ReceiveData();

But it does not work. Help please, thank you!

#i2c #stm8 #i2c-example
1 REPLY 1
pkumar1883
Associate II
Posted on February 06, 2016 at 10:51

Dear sakarya.erhan,

First debug your master, if it is generating correct waveform for init, start and stopn. You can see the master CLK and DATA pin on CRO or Logic Analyzer.

/*Please 

mark helpfull

 if this post helps you or solves your problem.*/

/**disclaimer**/

/* I am not a person from ST Technical Support Team. So please verify/test any support/suggestion at your end.*/

/* This post is only for general support purpose and free of any charge.If you need any personal support for your work please contact at 

embeddeddesign.help@gmail.com

*/