2020-02-04 5:41 AM
First I thouht that problem in code generation from Cube, rewrote all in CMSIS, but nothing changed.
I2C using only as a "slave", but after generation "start" and sending addres (0x70) + write no interrupt flags is set. Where my mistake?
Initialisation code here:
RCC->AHBENR|=RCC_AHBENR_GPIOBEN;
GPIOB->MODER|=GPIO_MODER_MODER6_1|GPIO_MODER_MODER7_1;
GPIOB->OSPEEDR|=GPIO_OSPEEDR_OSPEEDR6_0|GPIO_OSPEEDR_OSPEEDR7_0;
GPIOB->AFR[0]|=0x11000000;
RCC->APB1ENR|=RCC_APB1ENR_I2C1EN;
I2C1->CR1|=I2C_CR1_PE;
I2C1->CR1&=~I2C_CR1_PE;
I2C1->CR1|=I2C_CR1_TXIE|I2C_CR1_RXIE|I2C_CR1_STOPIE|I2C_CR1_ERRIE|I2C_CR1_ANFOFF
|I2C_CR1_ADDRIE;
I2C1->CR2|=I2C_CR2_NACK;
I2C1->OAR1|=I2C_OAR1_OA1EN;
I2C1->OAR1|=(0x70<<1);
I2C1->TIMINGR=0x00200000;
I2C1->CR1|=I2C_CR1_PE;
__enable_irq ();
HAL_NVIC_EnableIRQ(I2C1_IRQn);
Thank you for help.
2020-02-04 6:30 AM
I don't really get your point. A I2C slave will not send its address. It may only respond to a master read/write request.
for HAL I2C slave sample code look at my comment in "Connecting Raspberry PI to STM32F105xx via I2C". (Does the forum have permanent links for that?).
hth
KnarfB
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.