cancel
Showing results for 
Search instead for 
Did you mean: 

How using HAL function to put I2C slave to be ready for receiving and transmit at same time ?

bluenow1896
Associate III
Posted on November 01, 2016 at 13:01

.ExternalClassAC1DB71309B940C5BD54EFEF317A9B2C pre.cjk {font-family:'Courier New',monospace;} .ExternalClassAC1DB71309B940C5BD54EFEF317A9B2C p {margin-bottom:0.1in;line-height:120%;}

What I want to implement is to use I2C for communication between processors.

To simplify, one processor be I2C master and another be slave; I2C master sends

command by I2C Master transmit and checks state by I2C Master receive. I want to

setup the I2C slave to be ready to I2C slave transmit and I2C slave receive at

the same time, in another word, be read for I2C master to either issue command

or check status. I thought I can u

se

HAL_I2C_Slave_

Receive

_IT(�

)

and

HAL_I2C_Slave_Transmit_IT(�

),

but it seems like the second function

call will supersede the previous one, which leave the I2C slave be

ready to either transmit or receive but not both.

I use a STM32F0 for the I2C slave implementation.

#no-hablo-hal #i2c-slave #hal-i2c #i2c-slave-transmitter
4 REPLIES 4
bluenow1896
Associate III
Posted on November 03, 2016 at 02:28

.ExternalClass6AFB6B8A8D014AC0B561B4F44BE2CAE8 pre.cjk {font-family:'Courier New',monospace;} .ExternalClass6AFB6B8A8D014AC0B561B4F44BE2CAE8 p {margin-bottom:0.1in;line-height:120%;}

Hello, Could someone help on this? What I want to do is to prepare a STM32F0 on I2C slave interface to be ready for I2C write and read. I thought that could be done by call HAL i2c function of theHAL_Stattus = (HAL_I2C_Slave_Receive_IT(&I2CInterface, (uint8_t *)coI2CSlaveRxBuffer, COI2C_SLAVE_RXBUFFSIZE); and then theHAL_Stattus = HAL_I2C_Slave_Transmit_IT(&I2CInterface, (uint8_t*)coI2CSlaveTxBuffer, COI2C_SLAVE_TXBUFFSIZE); Actually the order shouldn’t be matter, but the problem is that the second call always failed while get returned status of HAL_BUSY instead of HAL_OK. I’m be wondering that should I use HAL i2c functions other than HAL_I2C_Slave_XXX_IT() ?

Posted on November 03, 2016 at 03:12

Could someone help on this?

The roster of contributing HAL talent here is pretty shallow. Perhaps some of the FAEs can step up?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bluenow1896
Associate III
Posted on November 03, 2016 at 17:02

.ExternalClass76539F173F7F4818AF5F265855EA369A pre.cjk {font-family:'Courier New',monospace;} .ExternalClass76539F173F7F4818AF5F265855EA369A p {margin-bottom:0.1in;line-height:120%;}

Just realized my second post was formatted so badly. Here I try to format it batter. Could someone help on this? What I want to do is to prepare a STM32F0 on I2C slave interface to be ready for I2C write and read. I thought that could be done by call HAL i2c function of

theHAL_Stattus = (HAL_I2C_Slave_Receive_IT(&I2CInterface, (uint8_t *)coI2CSlaveRxBuffer, COI2C_SLAVE_RXBUFFSIZE);
and then 
theHAL_Stattus = HAL_I2C_Slave_Transmit_IT(&I2CInterface,(uint8_t*)coI2CSlaveTxBuffer, COI2C_SLAVE_TXBUFFSIZE); 

Actually the order shouldn’t be matter, but the problem is that the second call always failed while get returned status of HAL_BUSY instead of HAL_OK. I’m be wondering that should I use HAL i2c functions other than HAL_I2C_Slave_***_IT() ?
Harvey White
Senior III
Posted on August 31, 2017 at 02:12

In a word,the HAL drivers are set to not allow this.  The chip itself probably can.  If you wish the chip to be transparent (slave receive to master transmit on another interface) the best way would be to pass a message between the two interfaces with your own software.  HAL would work in that case