I am trying to communicate with MAX30205 using STLUX385/STNRG388A.
I'm using STM8S standard peripheral libraries to communicate with I2C bus.
For STNRG388A device drivers, I'm using STLUX385 drivers provided by ST.
I can read/write GPIOs, UART communication successfully.
But when i tried the I2C bus communication, it's not working as expected.
My main.c code is below, rest of the task is in the stlux_it.c in INTERRUPT_HANDLER(I2C_IRQHandler,19)
void main ( void )
{
// work with HSI at maximum frequency
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
// enable PLL - Used by the SMED
CLK_PLLCmd(ENABLE);
while((CLK->PLLR & CLK_PLLR_LOCKP) == 0);
// initialize the GPIO registers
GPIO_Init(GPIO1, GPIO_PIN_6, GPIO_MODE_OUT_PP_HIGH_FAST);
GPIO_Init(GPIO1, GPIO_PIN_7, GPIO_MODE_OUT_PP_HIGH_FAST);
I2C_DeInit();
CLK_PeripheralClockConfig(CLK_PERIPHERAL_I2C, ENABLE);
I2C_Cmd(ENABLE);
I2C_Init(I2C_SPEED, SLAVE_ADDRESS, I2C_DUTYCYCLE_2, I2C_ACK_CURR, I2C_ADDMODE_7BIT,16);// (CLK_GetClockFreq()/1000000));
I2C_ITConfig((I2C_IT_TypeDef)(I2C_IT_EVT | I2C_IT_BUF), ENABLE);
rim();
/* TXBuffer initialization */
for (i = 0; i < BUFFERSIZE; i++)
TxBuffer[i] = i;
I2C_GenerateSTART(ENABLE);
while (NumOfBytes);
while (I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));
/* Add a delay to be sure that communication is finished */
Delay(0xFFFF);
while(1);
}
I have checked the MAX30205 with arduino and it's working fine. Waiting for any positive response. Thanks in advance. Regards
NumOfBytes
and how does it change values? \$\endgroup\$