Question
I2C no clock
NUCLEOWB55RG
I set I2C3 in MX. I have 2 x temp sensors & 2 x accelerometers in the bus.
/* Snippets of code to show how I2C3 is set up & used */
#include "main.h"
#include "adt7410.h"
#include "adxl345.h"
I2C_HandleTypeDef hi2c3;
ADT7410 temp_0;
ADT7410 temp_1;
ADXL345 acc_0;
ADXL345 acc_1;
static void MX_GPIO_Init(void);
static void MX_I2C3_Init(void);
int main(void)
{
HAL_Init();
MX_GPIO_Init();
MX_I2C3_Init();
/* ADT7410 set up */
/* temp_0 at 0x48
* temp_1 at 0x49 */
temp_0.adti2c = &hi2c3; // I2C Handler
ADT7410_Init(&temp_0, 0x48); // I2C address depends of A0 and A1 pins
ADT7410_Reset(&temp_0); // Optional
ADT7410_SetResolution(&temp_0, ADT7410_16BITS); // Put the device in 16 bits resolution
temp_1.adti2c = &hi2c3; // I2C Handler
ADT7410_Init(&temp_1, 0x49); // I2C address depends of A0 and A1 pins
ADT7410_Reset(&temp_1); // Optional
ADT7410_SetResolution(&temp_1, ADT7410_16BITS); // Put the device in 16 bits resolution
/* ADXL345 set up
* acc_0 at 0x1D, write 0x3A, read 0x3B
* acc_1 at 0x53, write 0xA6, read 0xA7
*/
acc_0.adxl345i2c = &hi2c3; // I2C handler - might have to change this
acc_1.adxl345i2c = &hi2c3; // ~CS needs to be tied to Vdd for I2C comms
ADXL345_Init(&acc_0, 0x1D, 0x3A, 0x3B); // ALT_ADDRESS tied to Vdd
ADXL345_Init(&acc_1, 0x53, 0xA6, 0xA7); // ALT_ADDRESS tied to GND
/* Init code for STM32_WPAN */
MX_APPE_Init();
while (1)
{
MX_APPE_Process();
}
}
static void MX_I2C3_Init(void)
{
/* USER CODE BEGIN I2C3_Init 0 */
/* USER CODE END I2C3_Init 0 */
/* USER CODE BEGIN I2C3_Init 1 */
/* USER CODE END I2C3_Init 1 */
hi2c3.Instance = I2C3;
hi2c3.Init.Timing = 0x0060112F;
hi2c3.Init.OwnAddress1 = 0;
hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c3.Init.OwnAddress2 = 0;
hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c3) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C3_Init 2 */
/* USER CODE END I2C3_Init 2 */
}
The BLE part is transmitting the sensor values back every second but they are all 0. When I check I2C3_SCL with a scope its just flat, same with I2C3_SDA, nothing on the line at all.
I tried with I2C1 and I cant even connect to the board via BLE. I have swapped out 3 boards now, same result. Unhooked all the sensors, still nothing on SCL & SDA.
