This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Not Getting Proper Status Responses of Repeated Start in I2C Protocol of LPC1343?

Hello!! Everyone i am working on LPC1343 Micro-controller and wants to interface RTCC PCF8523 with LPC1343.

I write code for I2C protocol but its not working.
The problem is found when i send repeated start from master (LPC1343), the status for this must be 0x10 while i am getting 0x28 every time.

The full code can be downloaded from here:-
www.edaboard.com/.../107170d1404924341-pcf8523_rtcc.zip
(Its EDABOARD Link Sorry, i dont know how to attach files here.)

The functions used for I2C Protocol are as follow:-

#include "LPC13xx.h"
#include "I2C.h"
#include "UART.h"

void I2C_Init(unsigned char Mode)
{
        LPC_SYSCON->PRESETCTRL |= (1<<1);                      //De-Asserts Reset Signal to I2C
        LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5);   //Enable I2C Clock

        LPC_IOCON->PIO0_4 &= ~0x3F;
        LPC_IOCON->PIO0_4 |= 0x01;   //SCL

        LPC_IOCON->PIO0_5 &= ~0x3F;
        LPC_IOCON->PIO0_5 |= 0x01;   //SDA

        if(Mode == I2C_SPEED_400)
        {
                LPC_I2C->SCLH = 90;                  //I2PCLK is 72MHz
                LPC_I2C->SCLL = 90;                  //I2PCLK is 72MHz
        }
        else if(Mode == I2C_SPEED_100)
        {
                LPC_I2C->SCLH = 360;         //I2PCLK is 72MHz
                LPC_I2C->SCLL = 360;         //I2PCLK is 72MHz
        }

        LPC_I2C->CONCLR = 0xFF;              //Clear All Flags
        LPC_I2C->CONSET = (1<<6);      //I2C Interface Enable
}
void I2C_Start(void)
{
        LPC_I2C->CONSET |= 0x20;                     //Set the Start Bit
        while(LPC_I2C->STAT!=0x08);          //Wait for the Status Bit
}
void I2C_Restart(void)
{
        LPC_I2C->CONSET |= 0x20;                     //Set the Start Bit
        while(LPC_I2C->STAT!=0x10);          //Wait for the Status Bit
}
void I2C_Stop(void)
{
        LPC_I2C->CONSET |= 0x14;     //Stop I2C
        LPC_I2C->CONCLR = 0x08;
}
void I2C_Write(unsigned char data,unsigned char status)
{
        LPC_I2C->DAT = data;
  LPC_I2C->CONCLR = 0X28;                                            //Clear Start Flag and SI Interrupt
  while(LPC_I2C->STAT!=status);                //Wait for the Status Byte
}
unsigned char I2C_Read(void)
{
  LPC_I2C->CONCLR = 0X28;
  while (LPC_I2C->STAT!=0x50);                       //Wait for Status Set - 0x50
  return(LPC_I2C->DAT);
}

In function Read from RTCC (given below)

unsigned char PCF8523_Read(unsigned char Address)
{
        unsigned char temp;
        I2C_Start();
        UART_Write('1');
        I2C_Write(PC8523_ADDRESS,0x18);
        UART_Write('2');
        I2C_Write(Address,0x28);
        UART_Write('3');
        I2C_Restart();
        UART_Write('4');
        I2C_Write(PC8523_ADDRESS+1,0x40);
        UART_Write('5');
        temp = I2C_Read();
        UART_Write('6');
        I2C_Stop();
        UART_Write('7');
        return temp;
}[/pre>

As i dont have debugger i checked the content of Status Bytes on UART, i found that for I2c_Start, the status byte contains 0x08 when sending rtcc address i am getting status = 0x18 and then after sending the address from where i have to read i am getting status = 0x28 which is correct.
Upto this point i am getting valid status responses, but after sending Repeated Start i am getting 0x28 each and every time continuously.
Can anyone please help me to solve this issue.


0