CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Raspberry B+ i2c PIC 18F4550 Slave problem.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
freebee



Joined: 25 Nov 2014
Posts: 1

View user's profile Send private message

Raspberry B+ i2c PIC 18F4550 Slave problem.
PostPosted: Tue Nov 25, 2014 11:21 am     Reply with quote

hi for all,

I am very novice in code and i want just send string from a pic to a raspberry pi. Raspberry b+ is just i2c master and pic just slave.

Code for i2c pic slave:
Code:
#include <18F4550.h>
#device adc=10
#fuses XT, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=20Mhz)
#define PIC_TRIS_B 0b00000011 // Input mode B0 and B1
#use i2c(Slave, Slow, sda=PIN_B0, scl=PIN_B1, address=0x08)


//==========================
void main()
{

i2c_start();
while(1)
  { 
   i2c_write(0x55);
   delay_us(500);
  }

}

The idea is just send a data to raspberry pi.
This code compiles, but no send data. Can somebody help me ?.
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Tue Nov 25, 2014 11:56 am     Reply with quote

Look at the slave example.

All I2C transactions are initiated by the master. A slave cannot send a start.

The slave has to wait for the master to send a data request, with the correct address, and _then_ load the byte for the reply.

As a comment, have you actually tested your PIC is working?. XT, and 20MHz, are _not_ legal clock settings.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 25, 2014 12:37 pm     Reply with quote

Here is a post that explains how to setup a simple i2c master and
slave, by using the CCS example file, ex_slave.c:
http://www.ccsinfo.com/forum/viewtopic.php?t=50861&start=1
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group