Se me traba al momento de entrar a la funcion ByteWriteI2C
#include <p18f4610.h>
#include <delays.h> //Libreria para los retardos
#include <stdlib.h> //Libreria para conversiones a string
#include <stdio.h>
#include <sw_uart.h>
#include <string.h>
#include <math.h>
#include <i2c.h>
#include "./Include/lcd_serial.h"
#include "./Include/LCD_CRYSTAL.h"
#include "./Include/Teclado.h"
#include "./Include/ds1302.h"
#pragma config OSC=HS,FCMEN=OFF,IESO=OFF
#pragma config PWRT=ON,BOREN=OFF,BORV=0,WDT=OFF,WDTPS=32768
#pragma config MCLRE=ON,LPT1OSC=OFF,PBADEN=OFF,CCP2MX=PORTBE
#pragma config STVREN=OFF,LVP=OFF,XINST=OFF,DEBUG=OFF
#pragma config CP0=OFF,CP1=OFF,CP2=OFF,CP3=OFF,CPB=OFF
#pragma config WRT0=OFF,WRT1=OFF,WRT2=OFF,WRT3=OFF,WRTB=OFF,WRTC=OFF
#pragma config EBTR0=OFF,EBTR1=OFF,EBTR2=OFF,EBTR3=OFF,EBTRB=OFF
unsigned char Data;
void ByteWriteI2C(unsigned char ByteControl,unsigned char HighDireccion,unsigned char LowDireccion,unsigned char DataI2C);
unsigned char ByteReadI2C(unsigned char ByteControl,unsigned char HighDireccion,unsigned char LowDireccion);
void main(void)
{
ADCON1=15;
OpenUART(); //Habilita los puerto de comunicación serial por software
// ds1302_init(); //Inicializa el reloj ds1302 para su funcionamiento
OpenI2C(MASTER,SLEW_OFF);
SSPADD=49;
Data=1;
Delay_ms(500);
WriteUART(0xFE);
WriteUART(0x01);
WriteLCD(" Prueba a Memoria",17);
ByteWriteI2C(0xA0,0x00,0x00,Data);
Delay1KTCYx(5);
//ByteReadI2C(0xA0,0x00,0x00);
Delay_ms(500);
WriteUART(0xFE);
WriteUART(0x01);
WriteLCD(" Prueba a Memoria 1",19);
}
void ByteWriteI2C(unsigned char ByteControl,unsigned char HighDireccion,unsigned char LowDireccion,unsigned char DataI2C)
{
IdleI2C();
StartI2C();
while(SSPCON2bits.SEN);
WriteI2C(ByteControl);
WriteI2C(HighDireccion);
WriteI2C(LowDireccion);
WriteI2C(DataI2C);
StopI2C();
while(SSPCON2bits.PEN);
while(EEAckPolling(ByteControl));
}
unsigned char ByteReadI2C(unsigned char ByteControl,unsigned char HighDireccion,unsigned char LowDireccion)
{
unsigned char Valor;
IdleI2C();
StartI2C();
while(SSPCON2bits.SEN);
WriteI2C(ByteControl);
WriteI2C(HighDireccion);
WriteI2C(LowDireccion);
RestartI2C();
while(SSPCON2bits.RSEN);
WriteI2C(ByteControl | 0x01);
Valor=ReadI2C();
NotAckI2C();
while(SSPCON2bits.ACKEN);
StopI2C();
while(SSPCON2bits.PEN);
return (Valor);
}