Hi everyone,

I'm trying to send a simple 16 bits of data with the !2CWrite, but in Proteus I2C Debugger, i see the message separated.
The odd thing is when the Device ID is $78, it works, with other value, it simple break the message...

Can anyone understand what's going on?


ASM
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L
__CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_OFF_2L & _BORV_2_2L & _VREGEN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM


DEFINE OSC 8 ' Velocidade padrão do 18F2550 qd em Internal Oscilator

'################################################# ##############################
' Default HSEROUT/IN do PIC #
'################################################# ##############################

'------------------------------ Time Variables ------------------------------

I2C_Address VAR Byte ' I2C - Comandos
Address_To Var Byte ' I2C - Comandos
Command var Byte ' I2C - Comandos
Command_2 var Byte ' I2C - Comandos


SDA VAR PortB.6
SCL VAR PortB.7


'----------------------------- Initial Settings --------------------------------

UCON.3 = 0 ' USB Disable, RC4 e RC5 Digital Input Only
UCFG.3 = 1 ' USB On-chip transceiver disabled

ADCON1 = %00001110 ' (5) Vss Referência, (4) Vdd Referência, (3-0) AN0 = Analog, restantes ANx Digitais
ADCON0 = %00000000 ' (5-2) An0 Selected, (0) A/D Module Off
ADCON2 = %10000000 ' (7) Right Justified, (5-3) A/D Acquisition Time - 0 Tad, (2-0) A/D Clock - FOSC/2

CMCON = 7 ' (2-0) 111-> Comparator Off
OSCCON = %01110000 ' (7) Enter Slepp Mode on Sleep Instruction, (6-4) 8 MHz, (1-0) 1x--> Internal Oscilator 00--> Primary Oscilator ???
' OSCTUNE = %00011111 ' Serve para fazer uma pequena afinação da velocidade do Clock do Processador

IntCon = %10010000 ' (7) Global Int Enabled, (4) Int0 - Enabled
IntCon2 = %00000000 ' (7) Pull_Ups Enabled, (6) Int0 - On Falling, (5) Int1 - On Falling, (4) Int2 - On Falling
IntCon3 = %00011000 ' Int1 - Priority Bit Off, (3) Int1 Enabled, (4) Int2 Enabled

TRISA = %00000001
TRISB = %00001111
TRISC = %10110000 ' O C.2 é definido como In, só qd é ligada a rega (PWM On), é q passa a Out.


'################################################# ##############################
'# Setup's #
'################################################# ##############################

Pause 500 ' Delay p PowerUp de todos os Devices
I2C_Address = $76
Address_To = $02
Command = $54
Command_2 = $70

Menu:
I2C_Address = I2C_Address +1

I2cWrite SDA,SCL,I2C_Address,Address_To,[Command,Command_2]
Pause 500

goto Menu


end


Thanks,
Nuno


Name:  I2CWrite_Proteus.JPG
Views: 433
Size:  32.9 KB