cancel
Showing results for 
Search instead for 
Did you mean: 

I2C how to generate NACK and STOP

mail239955_stm1_st
Associate II
Posted on September 01, 2015 at 00:33

Hello,

I'm using MCP3424 and it says in it's datasheet

When the Master finds the RDY bit is cleared, it can send a 
not-acknowledge (NAK) bit and a stop bit to exit the current 
read operation and send a new read command for the latest 
conversion data.

But HAL drivers does not simply let me to generate start, stop, nack. I can read the first channel of MCP3424 but i cannot switch to channel 2 or others. I need to make this steps, HAL_I2C_Master_Transmit(One-Shot Conversion of Channel 1 Config); HAL_I2C_Master_Receive(3 byte data); I2C_Send(NACK); I2C_Send(Stopbit); and then HAL_I2C_Master_Transmit(One-Shot Conversion of Channel 2 Config); HAL_I2C_Master_Receive(3 byte data); I2C_Send(NACK); I2C_Send(Stopbit); but i don't know how to send nack and stop bit to MCP3424 Any help? Thank you. #i2c #h
1 REPLY 1
Amel NASRI
ST Employee
Posted on September 07, 2015 at 17:22

Hi turkman.serhat,

I think that the actions you need to do are already managed by the HAL_I2C_Master_Receive. In fact, it do the following:

1- Transmit the Start bit with slave address followed by read bit

2- Received the number of desired bytes

3- Send the NACK + STOP bit.

So you have only to call HAL_I2C_Master_Receive. You can monitor the transferred data on the I2C bus thanks to SDA pin.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.