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.
Any help would be gratefully accepted