cancel
Showing results for 
Search instead for 
Did you mean: 

SMBus Alert

arapp1990
Associate II
Posted on November 16, 2015 at 16:39

Hi guys,

some days ago I had a similar question[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/I2CSMBus%20doesn%27t%20respond%20to%20ARA&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx&currentviews=28]here. Now I'm using the Standard Peripheral Library instead of HAL. I'd like to use the STM32F4 as SMBus slave supporting SMBAlert. The STM32 should pull down the SMBA Line and acknowledge to the Alert Response Address (0x18). After the ackthe slave should send its own address, so the master knows who was pulling down the SMBA pin, asdescribed

http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031pdf

on page 8 After setting the ALERT bit in I2C_CR1

I2C_SMBusAlertConfig(I2C1, I2C_SMBusAlert_Low);

the SMBA Pin is being pulled down and the ARA is acknowledged by the slave. Instead of sending its own address it sends 0x19, which looks like ARA changed the LSB to 1. 0690X00000605JhQAI.png Code:

void I2C_Config(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
I2C_InitTypeDef I2C_InitStruct;
GPIO_InitTypeDef GPIO_InitStructure;
/*
PB5 --> I2C1_SMBA
PB7 --> I2C1_SDA
PB8 --> I2C1_SCL
*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_7 | GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource5, GPIO_AF_I2C1); // I2C1_SMBA
GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_I2C1); // I2C1_SDA
GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_I2C1); // I2C1_SCL
I2C_DeInit(I2C1);
I2C_InitStruct.I2C_Mode = I2C_Mode_SMBusDevice;
I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStruct.I2C_OwnAddress1 = (16<<
1
);
I2C_InitStruct.I2C_Ack
= 
I2C_Ack_Enable
;
I2C_InitStruct.I2C_AcknowledgedAddress
= 
I2C_AcknowledgedAddress_7bit
;
I2C_InitStruct.I2C_ClockSpeed
= 
100000
;
I2C_StretchClockCmd(I2C1, DISABLE);
I2C_OwnAddress2Config(I2C1, (18<<1));
I2C_DualAddressCmd(I2C1, ENABLE);
I2C_ARPCmd(I2C1, ENABLE);
I2C_GeneralCallCmd(I2C1, ENABLE);
I2C_Cmd(I2C1, ENABLE);
I2C_Init(I2C1, &I2C_InitStruct);
I2C1->CR1 &= ~I2C_CR1_SMBTYPE; // 0->SMBus Device, p852
I2C1->CR1 |= I2C_CR1_SMBUS; // 1->SMBus mode, p853
}

Can you please give me any hints about what might be wrong? #smbus-i2c-alert-smbalert
0 REPLIES 0