PIC877A, 873A & I2C

General discussion on mikroElektronika website & forums.
Post Reply
Author
Message
dangerous
Posts: 748
Joined: 08 Mar 2005 16:06
Location: Nottinghamshire, UK

PIC877A, 873A & I2C

#1 Post by dangerous » 10 Mar 2005 12:55

Hello Good people,

I have recently started using your fantastic PIC Basic.

I am trying to talk to an I2C device Address $C0 ( a Philips TSA5515 PLL chip)

Loading and compiling code into a 16F877 or 877A works fine, but I cannot get it to work in an 873A. SDA remains hi and SCL sticks low as soon as the power up ends. I have tried in Basic and Pascal with the same result. I have read the datasheets until I cannot see, but the initialisations both look the same to me.

I have pared the sequences down until I have the minimum code and have copied my Pascal version below. Am I doing something silly? With the 877A the writes can be seen on the scope with a gap of about 15 mS
then the thing repeats, as it should. In the delay period SCL & SDA are high as they should be.

Code: Select all

program testme2;

{main procedure}
//******************************************************************************
// microcontroller P16F877A
//
// Project: pascalI2c
// This project is designed to work with PIC 16F877A;
// with minor adjustments, it should work with any other PIC MCU
// that has MSSP module.
//
// This code demonstrates comunication with 24c02 EEPROM
// connected to appropriate pins of portc.
// After byte is read, it is displayed on portd.
//******************************************************************************

var  Addr, EE_ByteOut, EE_ByteIn : byte;
label top;
begin

  top:
    I2C_init(100000);        // initialize I2C module 100 kHz clk, full master_ mode
    TRISA :=   0;            // designate porta as output
    PORTA:= $FF;            // initialize porta
    I2C_start;               // issue I2C start signal
    I2C_wr($c0);             // send byte via I2C  (command to 24cO2)
    I2C_wr($1f);            // send byte (address of EEPROM location)
    I2C_wr($e2);      // send data (data to be written)
    I2C_wr($A0);            // send byte (address of EEPROM location)
    I2C_wr($00);      // send data (data to be written)
    I2C_stop;                // issue I2C stop sinal
    PORTA:= $FE;            // change bit 0
    Delay_ms(15);
    goto top;

end.
This is the modified version of the EEprom example and works great with the 877 or 877A, not with the 873A (I have tried 4 873A chips all with the same result) A simple port test will clock all the ports OK so I do not think I have broken the chips.

Any help would be gratefully accepted

nikola
mikroElektronika team
Posts: 137
Joined: 03 Aug 2004 12:44
Contact:

Re: PIC877A, 873A & I2C

#2 Post by nikola » 10 Mar 2005 14:17

dangerous wrote:Hello Good people,

I have recently started using your fantastic PIC Basic.
Heh, you mean mikroBasic ..? :wink:

By the way, this topic should have been started in mikroBasic general, don't you think?

-
Best regards,
Nikola

pizon
mikroElektronika team
Posts: 823
Joined: 11 Oct 2004 08:53

Re: PIC877A, 873A & I2C

#3 Post by pizon » 11 Mar 2005 13:24

I'll check the I2C on 873A (hopefully) today, and let you know what I've dug out.
pizon

Dangerous2
Posts: 6
Joined: 12 Mar 2005 15:53

I2C and 873

#4 Post by Dangerous2 » 12 Mar 2005 16:32

Sorry Nikola,

Of course I did mean MikroBasic!!!

The reason I put it here was because the Pascal version did the same thing,
so I was at a bit of loss as to where to put the comment. :?

Post Reply

Return to “Website & Forums General Discussion”