2018-11-22 03:28 AM
Hello,
i try to get a most simple I2C driver to work. So, i setup I2C1 with CubeMX and select code generation.
In the resulting main.c, all i have to do is to add something like that:
/* USER CODE BEGIN WHILE */
while (1)
{
uint8_t value = 0;
for (uint32_t i = 0; i < 100000; i++)
asm("NOP");
HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)(0x27 << 1), (uint8_t*)&value, 1, 100);
This should be enough to see anything an my data logger, shouldn't it?
But all i see is SCL and SDA staying hijgh - no glitch no change.
Before you ask: The hardware is working as expected. I have this same device running with a Standard Peripheral Library driver (where i did hardware initialization by myself) wijthout problems.
So, what do i miss in this CubeMX project?
Best regards,
SF49ers
Solved! Go to Solution.
2018-11-22 12:32 PM
CubeMX generates the initialization code for the modules and so it does for I2C. The MX_I2C1_Init() is found in the main.c. But in my case, it was not added by CubeMX to the main function and so the initialization took not place. Adding it by hand does the job.
This is not a feature, is it?
2018-11-22 12:32 PM
CubeMX generates the initialization code for the modules and so it does for I2C. The MX_I2C1_Init() is found in the main.c. But in my case, it was not added by CubeMX to the main function and so the initialization took not place. Adding it by hand does the job.
This is not a feature, is it?