|
|
View previous topic :: View next topic |
Author |
Message |
freebee
Joined: 25 Nov 2014 Posts: 1
|
Raspberry B+ i2c PIC 18F4550 Slave problem. |
Posted: Tue Nov 25, 2014 11:21 am |
|
|
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: 19552
|
|
Posted: Tue Nov 25, 2014 11:56 am |
|
|
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
|
|
|
|
|
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
|