I2C slave mode, slave not respond to master
Hello everyone! I have been complaining about this for 1 week. I can't make "HAL_I2C_Slave_Seq_Transmit_IT" send data to the master, but Slave to master ACK works fine, does anyone have any advice to give me that can guide me a little? I am using the STM32F030. in another way i need the slave to respond to many ADDRESS for this i configure the mask to pass any address possible. Clock STRETCH or not dont affect this trouble.
The interruptions in "NVIC settings" are activated (i2C global interrupt), the frequency is the maximum possible (64Mhz) and the master speed is 20Khz, I have also tried with 100,400,1000 Khz and nothing worked, the Slave ACK perfectly in any frequency. in another way if i use "HAL_I2C_Slave_Seq_Receive_IT" slave receives data perfectly. in another way when i try to transmit data to master, im getting in
"HAL_I2C_GetError(hi2c);"
the error code 0x0A.... what this mean?
My code:
#define RxSIZE 100
uint8_t RxData[RxSIZE];
uint8_t TxData[RxSIZE];
uint8_t errorcode;
int countError = 0;
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c){
HAL_I2C_EnableListen_IT(hi2c);
}
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode){
if(TransferDirection == I2C_DIRECTION_TRANSMIT){
}else{
HAL_I2C_Slave_Seq_Transmit_IT(hi2c, TxData, 6, I2C_FIRST_AND_NEXT_FRAME);
}
}
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c){ // this function never called!!!!
}
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c){} //Not used But work if i Send data Master->Slave
/*
#define HAL_I2C_ERROR_NONE (0x00000000U) !< No error
#define HAL_I2C_ERROR_BERR (0x00000001U) !< BERR error
#define HAL_I2C_ERROR_ARLO (0x00000002U) !< ARLO error
#define HAL_I2C_ERROR_AF (0x00000004U) !< ACKF error
#define HAL_I2C_ERROR_OVR (0x00000008U) !< OVR error
#define HAL_I2C_ERROR_DMA (0x00000010U) !< DMA transfer error
#define HAL_I2C_ERROR_TIMEOUT (0x00000020U) !< Timeout error
#define HAL_I2C_ERROR_SIZE (0x00000040U) !< Size Management error
#define HAL_I2C_ERROR_DMA_PARAM (0x00000080U) !< DMA Parameter Error
*/
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c){
countError++;
errorcode = HAL_I2C_GetError(hi2c); // this responds -> 0x0A ????
HAL_I2C_EnableListen_IT(hi2c);
}
///////////////////// main //////////////////////////////////
/* USER CODE BEGIN 2 */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
for(uint16_t i=0;i<100;i++)TxData[i] = i;
while(HAL_I2C_GetState(&hi2c2)!=HAL_I2C_STATE_READY);
if(HAL_I2C_EnableListen_IT(&hi2c2)!= HAL_OK){
countError++;
}
while (1);


