cancel
Showing results for 
Search instead for 
Did you mean: 

I don't know why STM32F427 I2C3 will send the byte repeat?

yongjie989
Associate II
Posted on March 04, 2016 at 17:38

Hi all,

Are there have any one know this problem, I have to trying send only one byte via I2C3, but

I 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;

0690X00000605N4QAI.png

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 #i2c3
2 REPLIES 2
Posted on March 04, 2016 at 18:55

Wouldn't you need to wait for the register to free up before jamming in the next value?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yongjie989
Associate II
Posted on March 05, 2016 at 07:58

I have try to wait, but still show same result. But if I use I2C1, I2C1 is no this issue.