Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Mikro C, PIC16f877a and I2C

Status
Not open for further replies.

Khiri Alasiri

Newbie level 4
Newbie level 4
Joined
Jul 5, 2013
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
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,
 
Look at the mikroC I2C library function and routines: https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/i2c_library.htm

6917200700_1373097734.png


Hope this helps.
Tahmid.
 
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: 118

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top