Associate
August 1, 2014
Question
Nucleo F0: Problem with I2C
- August 1, 2014
- 5 replies
- 1339 views
Posted on August 01, 2014 at 15:59
I2C_HandleTypeDef hi2c1;
int main()
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_I2C1_Init();
HAL_I2C_Init(&hi2c1);
if(!(HAL_OK == HAL_I2C_IsDeviceReady(&hi2c1,0x39,1,1000)))
__ASM(''NOP'');//Breakpoint
}
void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x1042C3C7; //value calculated as described in Ref. Man.
hi2c1.Init.OwnAddress1 = 0x21;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
HAL_I2C_Init(&hi2c1);
HAL_I2CEx_AnalogFilter_Config(&hi2c1, I2C_ANALOGFILTER_DISABLED);
} Hello,
I'm trying to communicate with a slave device (Adafruit TSL2561, I²C-Address: 0x39).
I made a fast project using STM32 CubeMX and adapted it.
However, the output of the Pins is not correct, see the attached screenshot (Addr. 0x38 instead of 0x39).
Can anyone tell me what I did wrong?
Thank you in advance!