cancel
Showing results for 
Search instead for 
Did you mean: 

PMBus/SMBus with STM32F072 and HAL_SMBUS_Master_Transmit_IT() - Repeated start issue?

Christian Wächter
Associate III
Posted on July 10, 2018 at 15:54

Hello everyone,

I want to connect one LM5066 to a STM32F072 (currently a Nucleo) via the provided SMBus/PMBus. Unfortunatelly the configuration and daata transmission seem to be very different from I2C, that I already got working on the same port before.

I know that there is a SMBus Stack from ST, but I would like to prevent the usage of this because it has too much overhead for my application. So I found a chart in AN4502 (DocID026406 Rev 2) on page 34, that shows the commands. But with theses, I do not get a answer from the LM5

I can access the LM5066 with a USB to I2C/SMBus adapter with a MCP2221 with no problems. But these signals look totally different compared to the ones output by the STM

Anyone had to do with the SMBus on the STM32F072 and without the overloaded SMBus Stack, but the HAL?

This is the code of my testproject:

void MX_I2C1_SMBUS_Init(void)
{
 hsmbus1.Instance = I2C1;
 hsmbus1.Init.Timing = 0x2000090E;
 hsmbus1.Init.AnalogFilter = SMBUS_ANALOGFILTER_ENABLE;
 hsmbus1.Init.OwnAddress1 = 2;
 hsmbus1.Init.AddressingMode = SMBUS_ADDRESSINGMODE_7BIT;
 hsmbus1.Init.DualAddressMode = SMBUS_DUALADDRESS_DISABLE;
 hsmbus1.Init.OwnAddress2 = 0;
 hsmbus1.Init.OwnAddress2Masks = SMBUS_OA2_NOMASK;
 hsmbus1.Init.GeneralCallMode = SMBUS_GENERALCALL_DISABLE;
 hsmbus1.Init.NoStretchMode = SMBUS_NOSTRETCH_DISABLE;
 hsmbus1.Init.PacketErrorCheckMode = SMBUS_PEC_DISABLE;
 hsmbus1.Init.PeripheralMode = SMBUS_PERIPHERAL_MODE_SMBUS_HOST;
 hsmbus1.Init.SMBusTimeout = 0x00008061;
 if (HAL_SMBUS_Init(&hsmbus1) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }
}
void HAL_SMBUS_MspInit(SMBUS_HandleTypeDef* smbusHandle)
{
 GPIO_InitTypeDef GPIO_InitStruct;
 if(smbusHandle->Instance==I2C1)
 {
 /* USER CODE BEGIN I2C1_MspInit 0 */
 /* USER CODE END I2C1_MspInit 0 */
 
 /**I2C1 GPIO Configuration 
 PB6 ------> I2C1_SCL
 PB7 ------> I2C1_SDA 
 */
 GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
 GPIO_InitStruct.Pull = GPIO_PULLUP;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 GPIO_InitStruct.Alternate = GPIO_AF1_I2C1;
 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 /* I2C1 clock enable */
 __HAL_RCC_I2C1_CLK_ENABLE();
 /* I2C1 interrupt Init */
 HAL_NVIC_SetPriority(I2C1_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(I2C1_IRQn);
 /* USER CODE BEGIN I2C1_MspInit 1 */
 /* USER CODE END I2C1_MspInit 1 */
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
while (1)
{
volatile uint8_t SMBus_data[4] = {0x01, 0, 0, 0};
HAL_SMBUS_Master_Transmit_IT(&hsmbus1, 0x16, SMBus_data, 4, SMBUS_FIRST_FRAME);

//HAL_SMBUS_MasterTxCpltCallback(&hsmbus1);
// Receive should be 0x8083
HAL_SMBUS_Master_Receive_IT(&hsmbus1, 0x16, SMBus_data, 4, SMBUS_LAST_FRAME_NO_PEC);
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

#hal_smbus_master_receive_it #stm32f072 #pmbus #hal_smbus_master_transmit_it #smbus
0 REPLIES 0