Jump to content
mityeltu

I2C Master/slave - Slave Not Responding

Recommended Posts

//SLAVE CODE
sspcon.CKP = 0;
sspbuf = 22;
sspcon1.WCOL = 0;
sspbuf = 0x22;
sspcon.CKP = 1;

//MASTER CODE
i2c_start();
i2c_write(i2c_slave_add | 0x01);	//	write to slave
i2c_write(0x04);	//	write command "Read_Temp"
//wait till sspbuf is full, then read out the data
i2c_read(1);
while(!sspstat.BF);
UART_SendString("  Temp: ");
t_dat = sspbuf;
itoa(sspbuf,buff,10);	//	prepare for uart
UART_Write_Text(buff);	//	send data to uart
i2c_stop();

I have managed to get a master slave system working (mostly) with a pair of 16F1519 chips. I am certain the I2C is working as I am able to make an LED on the slave turn on/off and blink on command from the master.

 

I am now trying to have the slave send data back to the master, but I'm not getting anything back. I have tried several arrangements on both the master and slave to get data back, biut nothing yet. Does anyone have a working snippet I can see on how the master sends to get the data and the slave responds to send the data?

 

My code is below for anyone who wants to try their luck at deciphering my madness. Still not sure why the code always gets stuck at the top of this.

 

 

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×