I2C_Is_Idle - PIC18F452 vs PIC18F4520

General discussion on mikroPascal.
Post Reply
Author
Message
yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

I2C_Is_Idle - PIC18F452 vs PIC18F4520

#1 Post by yo2lio » 09 Apr 2008 21:28

Hi,

Both PIC18F452 and PIC18F4520 use the same I2C library : I2C_c34.ppas

Following short routine work good on PIC18F4520 and don't work on PIC18F452. Problem is I2C_Is_Idle routine.

Code: Select all

procedure SI2C_Write(ee_adr : Word; ee_data : byte);
var i : byte;
begin
  I2C_Start;                                // Issue I2C start signal
  I2C_Wr($A0);                              // Send byte via I2C
  I2C_Wr(hi(ee_adr));                       // Send byte(address for EEPROM)
  I2C_Wr(lo(ee_adr));                       // Send byte(address for EEPROM)
  I2C_Wr(ee_data);                          // Send data(data that will be written)
  I2C_Stop;                                 // Issue I2C stop signal
  i := 0;
  while i < 10 do
    begin
      delayms(1);
      I2C_Start;                            // Issue I2C start signal
      I2C_Wr($A0);                          // Send byte via I2C
      if (I2C_Is_Idle) then break;
      inc(i);
    end;
end;
If I replace while loop with delay_ms(10), everything it's OK.

Now, from datasheet :

For PIC18F452 (refer to SSPSTAT.2) : "ORing this bit with SEN, RSEN, PEN, RCEN, or ACKEN will indicate if the MSSP is in IDLE mode."

For PIC18F4520 (refer to SSPSTAT.2) : "ORing this bit with SEN, RSEN, PEN, RCEN or ACKEN will indicate if the MSSP is in Active mode."

Has someone experience with I2C_Is_Idle and PIC18F452 ???
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Post Reply

Return to “mikroPascal General”