I'm trying for some days make a comunication between two pics's, but it don't work. I need same simple example about I2C or/and SPI, that implement a comunication between a PIC 16f873 and 18f452. My compiler version is 3.082
Sorry about the poor english.
Antonio
___________________________
This message was ported from CCS's old forum
Original Post ID: 11301
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
Re: I need I2C or SPI examples
Posted: Wed Feb 05, 2003 4:44 pm
<font face="Courier New" size=-1>:=I'm trying for some days make a comunication between two pics's, but it don't work. I need same simple example about I2C or/and SPI, that implement a comunication between a PIC 16f873 and 18f452. My compiler version is 3.082
:=
:=Sorry about the poor english.
:=
:=Antonio
You can use the SS pin to keep the chips in sync
Wire a master pin to slave SS
Wire the master SCK (out) to slave SCK (in)
Wire the master SDI (in) to slave SDO (out)
Wire the master SDO (out) to slave SDI (in)
On the master
initialize port
setup_spi( spi_master | spi_l_to_h | spi_clk_div_16 );
Set Slave select pin low
output_low(PIN_A0);
Send byte Y /recieve byte X
X1 = spi_read(Y1);
X2 = spi_read(Y2);
Set slave select high
output_high(PIN_A0);
Two bytes were sent two recieved
On the slave
initialize port
setup_spi( spi_slave | spi_l_to_h );
Wait for SS to go low
while ( input(PIN_A5) );
Send byte X /recieve byte Y
Y1 = spi_read(X1);
Y2 = spi_read(X2);
wait for SS to go high
while ( !input(PIN_A5) );
Two bytes were sent two recieved
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11320
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