реклама на сайте
подробности

 
 
> не работает ответ i2c от stm32 в режиме slave, HAL
Метценгерштейн
сообщение Jun 2 2016, 13:20
Сообщение #1


Профессионал
*****

Группа: Свой
Сообщений: 1 357
Регистрация: 12-04-05
Из: Петербург
Пользователь №: 4 079



Коллеги, подскажите, как запустить корректно?

Проц STM32F030R8T6

если делать на прерываниях на HAL, то
Код
while (HAL_I2C_Slave_Transmit_IT( &hi2c1, TxBuf, (sizeof(TxBuf)/sizeof(TxBuf[0])) ) != HAL_OK)
    ;

так я отлично принимаю от мастера данные.

Если мастер меня запрашивает что- то, то как мне ему выдать данные? Как только что-то пытаюсь передать или просто, или на прерываниях, сразу шина зависает. И последующая запись идет с write filed.

Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
Lagman
сообщение Jun 4 2016, 16:33
Сообщение #2


Знающий
****

Группа: Свой
Сообщений: 875
Регистрация: 28-10-05
Пользователь №: 10 245



В примерах такая последовательность указана
Код
  /*##-2- Put I2C peripheral in reception process ###########################*/  
  if(HAL_I2C_Slave_Receive_IT(&I2cHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
  {
    /* Transfer error in transmission process */
    Error_Handler();        
  }
  
  /*##-3- Wait for the end of the transfer ###################################*/  
  /*  Before starting a new communication transfer, you need to check the current  
      state of the peripheral; if it’s busy you need to wait for the end of current
      transfer before starting a new one.
      For simplicity reasons, this example is just waiting till the end of the
      transfer, but application may perform other tasks while transfer operation
      is ongoing. */  
  while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY)
  {
  }

  /*##-4- Start the transmission process #####################################*/  
  /* While the I2C in reception process, user can transmit data through
     "aTxBuffer" buffer */
  if(HAL_I2C_Slave_Transmit_IT(&I2cHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)
  {
    /* Transfer error in transmission process */
    Error_Handler();    
  }
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 19th August 2025 - 17:02
Рейтинг@Mail.ru


Страница сгенерированна за 0.01369 секунд с 7
ELECTRONIX ©2004-2016