Fram write/read error, with stm3wb55?
Good afternoon to all forum members. I have a problem with stm32wb55 and i2c protocol. I use i2c (hi2c3) with the connected peripherals Ad7746, adxl345, mcp9808 and they work fine, but if I join fram MB85RC256v, with the write/read in the routine I write above, the result is always 0. On Mcu stm32f4 and stm32f103 works fine, but on stm32wb family it doesn't. Where is the error?
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define AD7746_address 0x90 //AD7746 ok work
#define Adxl345_address 0x53<<1 // Adxl345 ok work
#define MB85RC256v_Fram_address 0x50 or 0x50<<1 // Fram MB85RC256v not work
#define T9808_address 0x18<<1 // MCP9808 work
/* USER CODE END PD */
I2C_HandleTypeDef hi2c3;
/*..
*/
static void MX_I2C3_Init(void);
//---
void write_fram8(uint16_t addr,uint8_t wdatafram_8)
{
HAL_I2C_Mem_Write(&hi2c3, MB85RC256v_Fram_address,addr,0xFF,&wdatafram_8,1,10);
}
uint8_t read_fram8(uint16_t addr)
{
HAL_I2C_Mem_Read(&hi2c3, MB85RC256v_Fram_address,addr,0xFF,& rdatafram_8,1,10);
return rdatafram_8;
}
//...
int main(void)
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_USB_PCD_Init();
MX_I2C3_Init();
MCP9808_Init();
AD7746_Init();
adxl_Init();
for (int i=0; i<100; i++)
{
write_fram8(i,i);
HAL_Delay(50);
printf(" position: %d value: %X \r\n ", i, le_fram8(i));
}
RESULT
position: 0 value 0;
position: 1 value 0;
position: 2 value 0;
position: 3 value 0;
position: 4 value 0;
...
position: 99 value 0;
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 = 0x00707CBB;
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 */
}
