I have it working kinda... It is real sensitive to having the slave ready and waiting, which is not possible because I ultimately need the slave to do more involved tasks.

I have attached the code below with comments of my remaining issues. ANy further help would be great!

' PicBasic Pro Master PIC18F2220 to read and write to I2C slave

@ __CONFIG _CONFIG1H, _INTIO2_OSC_1H
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG3H, _MCLRE_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L

OSCCON = $70
DEFINE OSC 8

' Set up serial UART
define HSER_RCSTA 90H ' Set Receive Status and control register
DEFINE HSER_TXSTA 24H ' set transmit status and control register
'DEFINE HSER_BAUD 4800 ' 2403=2400Kbps, 9615=9600Kbps,19231=19.2Kbps
DEFINE HSER_BAUD 9615 ' 2403=2400Kbps, 9615=9600Kbps,19231=19.2Kbps
define HSER_CLROERR 1 ' reset on serial buffer overflow
'RCIF VAR PIR1.5 ' UART receive interrupt flag

' Define Analog parameters
ADCON0 = %00010001 '
ADCON1 = %00001100 ' Anolog AN0-AN4, all else digital
ADCON2 = %10000111 ' right justify result
CMCON = %00000111 ' Comparators OFF to allow inputs on pins CMCON = 7
INTCON = %00000000 ' all interrupts OFF
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS

DEFINE I2C_HOLD 1
DEFINe I2C_SLOW 1 'access a standard speed device at above 8MHz
SCL VAR PORTC.3 ' Clock pin
SDA VAR PORTC.4 ' Data pin

' Alias pins (0=Output, 1=Input)
L1 VAR LATB.7 :TRISB.7 = 0
L2 VAR LATB.6 :TRISB.6 = 0
L3 VAR LATB.5 :TRISB.5 = 0
L4 VAR LATB.4 :TRISB.4 = 0

'Define RAM
i var byte
a VAR BYTE[4] ' Holds 8 characters read from slave
j var byte

'blink L1-L4 to signal its alive or has been reset
for i = 1 to 12
high L1: pause 25: low L1
high L2: Pause 25: Low l2
high l3: pause 25: low l3
high l4: pause 25: low l4
next i
j= 125

loop:
toggle L1
j= j+1
I2CWrite SDA,SCL,$02,[j], bogus ' Write value to slave
if j>130 then
j=125
pause 1
I2CRead SDA,SCL,$02,[STR a\4], bogus ' Read string from slave
endif
hserout ["DATA 0:",dec a[0]," 1:",dec a[1]," 2:",dec a[2]," 3:",dec a[3]," 4:", dec a[4] ," ",13]
'a[0-2] are the slave analogs, it seems to be reporting back the right numbers :-)
'a[3] should be readcnt from master, its just toggles between 2 and 3??
'a[4] should be datain from the slave. j is toggling LED in slave, so the number is
' being sent, its just not getting returned, it only send back an 8 :-(
Pause 250
GoTo loop

bogus:
high l2: Pause 1000: low l2
GoTo loop


' PicBasic Pro I2C slave program - PIC16F819

@ device INTRC_OSC_NOCLKOUT
@ DEVICE WDT_ON ' Watchdog Timer
@ DEVICE PWRT_ON ' Power-On Timer
@ DEVICE BOD_ON ' Brown-Out Detect
@ DEVICE MCLR_OFF ' Master Clear Options
@ DEVICE LVP_OFF ' Low-Voltage Programming
@ DEVICE CPD_OFF ' Data Memory Code Protect
@ DEVICE PROTECT_OFF ' Program Code Protection

OSCCON = $70 'sets the oscillator speed
DEFINE OSC 8 'Oscillator speed in MHz: 3(3.58) 4 8 10 12 16 20 24 25 32 33 40

' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000100 ' Set A2 A4 digital, A0 A1 A3 Analog, rt justify

AN0 var word ' average Positioning Potentiometer Voltage
AN1 var word ' Trim Pot 1
AN3 VAR WORD ' Trim Pot 2
AN0i var word ' Positioning Potentionmeter

' Alias pins (0=Output, 1=Input)
scl VAR PORTB.3: TRISB.3 = 1 ' I2C clock input
sda VAR PORTB.4: TRISB.4 = 1 ' I2C data input
L1 var PORTA.2 :TRISA.2 = 0
L2 VAR PORTA.4 :TRISA.4 = 0
L3 VAR PORTB.0 :TRISB.0 = 0
L4 VAR PORTB.3 :TRISB.3 = 0 ' Green LED
L5 VAR PORTB.6 :TRISB.6 = 0 ' Red LED

' Define used register flags
DEFINe I2C_SLOW 1 'access a standard speed device at above 8MHz
SSPIF VAR PIR1.3 ' SSP (I2C) interrupt flag
BF VAR SSPSTAT.0 ' SSP (I2C) Buffer Full
R_W VAR SSPSTAT.2 ' SSP (I2C) Read/Write
D_A VAR SSPSTAT.5 ' SSP (I2C) Data/Address
CKP VAR SSPCON.4 ' SSP (I2C) SCK Release Control
SSPEN VAR SSPCON.5 ' SSP (I2C) Enable
SSPOV VAR SSPCON.6 ' SSP (I2C) Receive Overflow Indicator
WCOL VAR SSPCON.7 ' SSP (I2C) Write Collision Detect

' Define constants
I2Caddress CON 2 ' Make our address 2

' Allocate RAM
result VAR BYTE ' ADC result
datain VAR BYTE ' Data in
dataout VAR BYTE[4] ' Data out array
readcnt VAR BYTE ' I2C read count

' Initialize I2C slave mode
SSPADD = I2Caddress ' Set our address
'SSPCON2 = 0 ' General call address disabled
SSPCON = $36 ' Set to I2C slave with 7-bit address
readcnt = 0 ' Zero counter

low L1: low L2: low L3: low L4 : Low L5

GoTo mainloop ' Skip over subroutines

i2cslave: ' I2C slave subroutine
SSPIF = 0 ' Clear interrupt flag
IF R_W = 1 Then i2crd ' Read data
IF BF = 0 Then i2cexit ' Nothing in buffer so exit
IF D_A = 1 Then i2cwr ' Data for us (not address)
IF SSPBUF != I2Caddress Then i2cexit ' Clear the address from the buffer
readcnt = 0 ' Mark as first read
GoTo i2cexit

i2cwr: ' I2C write data to us
datain = SSPBUF ' Put data into array
toggle l2
if datain = 127 then
high l5
else
low l5
endif
'this is toggling, so the master is sending the number is its toggling the led, so apears good
'I want to receive more than on byte, how do I do this?
GoTo i2cexit

i2crd: ' I2C read data from us
IF D_A = 0 Then
'toggle l3 'this causes master to continously reset, too much of a pause?
readcnt = 0 ' Mark as first read
EndIF
SSPBUF = dataout[readcnt] ' Get data from array
CKP = 1 ' Release SCL line
readcnt = readcnt + 1 ' Move along read count
GoTo i2cexit ' That's it

i2cexit:
Return

mainloop: ' Main program loop
' have to check12c every step of both PICs lock up. Need a way of doing this as an iterupt??
' I plan on having a lot of other code the slave needs to execute, It is not practical to
' be continously checking like this...
gosub checki2c
toggle l1
gosub checki2c
ADCIN 0, AN0 ' Read ADC channel 0
gosub checki2c
AN0 = an0/4
gosub checki2c
dataout[0] = AN0

gosub checki2c
ADCIN 1, AN1
gosub checki2c
AN1 = an1/4
gosub checki2c
dataout[1] = AN1

gosub checki2c
ADCIN 3, AN3
gosub checki2c
AN3 = an3/4
gosub checki2c
dataout[2] = AN3

gosub checki2c
dataout[3] = readcnt

gosub checki2c
dataout[4] = datain
'this value is not getting back to the master???/

GoTo mainloop ' Do it all forever

checki2c:

'Check for I2C interrupt flag
IF SSPIF Then
GoSub i2cslave
EndIF

return