2016-03-04 08:38 AM
Hi all,
Are there have any one know this problem, I have to trying send only one byte via I2C3, butI don't know why STM32F427 I2C3 will send the byte repeat? uint32_t I2C_WrBuf(I2C_TypeDef* I2Cx, uint8_t DevAddr, uint8_t *buf, uint32_t cnt) { I2Cx->CR1 |= I2C_CR1_START; I2Cx->DR = (DevAddr << 1) | I2C_Direction_Transmitter; I2Cx->DR = 0x30; /* Here is very simple to send one byte */ I2Cx->CR1 |= I2C_CR1_STOP;Below is I2C3 config. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA , ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC , ENABLE); GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_I2C3); GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_I2C3); GPIO_InitStructure.GPIO_Pin = 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(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_Init(GPIOC, &GPIO_InitStructure); RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C3, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, DISABLE); I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_OwnAddress1 = 0x00; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = 50000; I2C_Init(I2Cx, &I2C_InitStructure); I2C_Cmd(I2Cx, ENABLE); #stm32f427 #i2c32016-03-04 09:55 AM
Wouldn't you need to wait for the register to free up before jamming in the next value?
2016-03-04 10:58 PM