[SOLVED] Mikro C, PIC16f877a and I2C

Status
Not open for further replies.

Khiri Alasiri

Newbie level 4
Joined
Jul 5, 2013
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
46
How can I send ACK or NACK signal via I2C, because the mikroC did not mention any thing about it.
 

Hi there,

These links might be helpful for you.

https://ww1.microchip.com/downloads/en/devicedoc/i2c.pdf

In MCU main pdf(page No.83)
SSPCON2: MSSP CONTROL REGISTER 2 (I2C MODE) (ADDRESS 91h)



bit 6 ACKSTAT: Acknowledge Status bit (Master Transmit mode only)
1 = Acknowledge was not received from slave
0 = Acknowledge was received from slave
bit 5 ACKDT: Acknowledge Data bit (Master Receive mode only)
1 = Not Acknowledge
0 = Acknowledge
Note: Value that will be transmitted when the user initiates an Acknowledge sequence at the end of a receive.
bit 4 ACKEN: Acknowledge Sequence Enable bit (Master Receive mode only)
1 = Initiate Acknowledge sequence on SDA and SCL pins and transmit ACKDT data bit.Automatically cleared by hardware.
0 = Acknowledge sequence Idle

Best regards,
 
Dear Jinzpaul4u
Dear Tahmid

I really appreciate your kind help.

I designed my MCU to work as master and the sensor as a slave. I have understood that when the master send a byte, the slave must send ACK bit. So, should I program my MCU to wait for every ACK.

Please correct me if I misunderstand.
 

Hi there,

This very simple program shows how to communicate between PIC16F1784 and a 16K I2C Serial EEPROM (24LC16B) using the MSSP port on the PICmicro.
 

Attachments

  • 16F1784_I2C_EEPROM.txt
    16.7 KB · Views: 90

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…