Searching \ for 'I2C Slave Code Problems' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/i2cs.htm?key=i2c
Search entire site for: 'I2C Slave Code Problems'.

Truncated match.
PICList Thread
'I2C Slave Code Problems'
2000\06\12@113218 by Bobby R. Bramlett

flavicon
face
I have exhaustively searched the PICLIST archives concerning slave mode
implementation
in the 16C6X family and I have not been able to find an answer to my
problem. I am connecting two PICS together and communicating via I2C.  The
master PIC is bitbanging
its data and seems to work properly.  The slave PIC is using its internal
I2C hardware
and interrupts.  I can write to the slave device but when I send a read
command it
grabs control of the SCL line and will not release it.  At multiple points
in the code
I have set the CKP bit of SSPCON.  However the SCL line is not released.  In
my
interrupt routine I check to see if the received address byte has the read
bit set.
If it does then I load SSPBUF with the outgoing data and set the CKP bit of
SSPCON.
Does anyone have code showing how they have utilized the slave mode hardware
to read
data from a PIC?

==============================================
= Bobby R. Bramlett
= Lufkin Automation
= Houston, TX
= (281)988-4419
==============================================

2000\06\12@114236 by Peter Schultz

flavicon
face
Hi Bobby,
I have only HiTech C rutin.
Peter

void init_spi_communication ( void )
{
 TRISC4 = 1;   //SPI Slave In
 TRISC5 = 0;   //SPI Slave Out
 TRISC3 = 1;   //SPI Slave CLK In
 TRISA5 = 1;   //SPI SS Enabled In, used for other purpose then SPI
    SMP = 0;   //SPI slave mode
  SSPEN = 1;   //SPI port pins enabled
  SSPM0 = 0;   //Slave Mode SS pin Disabled
  SSPM1 = 0;
  SSPM2 = 1;
  SSPM3 = 0;
    CKP = 1;   //Clock idle is high
    CKE = 0;   //Data on rising edge
}

void main ( void )
{
 hardware_init();
 initialize ();
 init_spi_communication ();    // Initialization of SPI
 SSPBUF = 0x00;                        // Clear SPI receive buffer
 SSPIE = 1;                      // Enable interrupt on SPI receiving
 PEIE = 1;                             // Enable peripherial interrupt(For
SPI)
 ei();                         // Global interrupt enable
 asm("sleep");                 // Going to sleep
 while (1)
  ;
}

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...