so I am currently trying to Read and Write the time to the RTC and these methods will just not work.
this is what I have: so it sends the address byte to determine where it would like to read from then flips the pin to input and reads each bit out until the byte is complete.
char ReadByte(char ByteToRead)
{
RB0 = 0; // ensure CLK low
RB5 = 1;
char received = 0;
int i;
for(i =0;i < 8 ;i++)
{
RB4 = ByteToRead & 1;
RB0 = 0;
ByteToRead >>= 1;
RB0 = 1;
}
TRISB4 = 1;//B4 = input port
for(i =0;i < 8 ;i++)
{
received |= RB4;
RB0 = 1;
received <<= 1;
RB0 = 0;
}
RB5=0;
TRISB4 = 0;
return DecimalToBCD(received);
}
the second sample is my write method:
void WriteByte(char ClockReg ,char data)
{
RB0 = 0; // ensure CLK low
RB5 = 1; // raises RST bit
int i;
for(i =0;i < 8 ;i++)
{
RB4 = ClockReg & 1;
RB0 = 0;
ClockReg >>= 1;
RB0 = 1;
}
for(i =0;i < 8 ;i++)
{
RB4 = data & 1;
RB0 = 0;
data >>= 1;
RB0 = 1;
}
RB5 = 0;
__delay_us(1);
RB5 = 1;
}
this does the same for the first bit to determine the register the write the value you give it.
the only help I can find online are links to a 2 year old page where there is no code or help just people asking to be PMed. So please if you can help
Thanks in advance