EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

I2C examples for LPC2148

Started by "shahin.ghazinouri" August 21, 2006
Hello,

I was wondering if anyone knows where I can find a working Keil I2C
example for LPC2148.
What I want to do is to use the I2C bus to send commands to a Philips
Display Driver chip (PCF-8535) and it would help if I had some example
code to use as basis.

Ill appriciate any help I can get!

/Shahin



An Engineer's Guide to the LPC2100 Series

----- Original Message -----
From: "shahin.ghazinouri"
To:
Sent: Monday, August 21, 2006 1:58 PM
Subject: [lpc2000] I2C examples for LPC2148
>Hello,

>I was wondering if anyone knows where I can find a working Keil I2C
>example for LPC2148.
>What I want to do is to use the I2C bus to send commands to a Philips
>Display Driver chip (PCF-8535) and it would help if I had some example
>code to use as basis.

>Ill appriciate any help I can get!

Take a look at the WIZnet demo in the FreeRTOS.org download. This has an
I2C link to a TCP/IP co-processor. LPC2106 rather than LPC2148, and GCC
rather than Keil, but its just C code so not that dependent on the compiler.

Regards,
Richard.

http://www.FreeRTOS.org
for Cortex-M3, ARM7, ARM9, HCS12, H8S, MSP430
Microblaze, Coldfire, AVR, x86, 8051 & PIC18 * * * *
Thanks for the advice. Ill look over it more carefully tomorrow, but it
seems a little bit over my head.
What Id like is the simplest code possible to send data over the I2C bus.
Ive found some examples and written the code below, Im not sure its
entirely correct though, would it be enough to call "I2CTransferbyte" with
the adress of the display driver and the command I want to send?

#include

unsigned I2CAddress;
unsigned I2CData;

void I2CISR (void)
{
switch (I2C0STAT)
{
case (0x08):
I2C0CONCLR=0x20;
I2C0DAT=I2CAddress;
break;

case (0x18):
I2C0DAT = I2CData;
break;

case (0x20):
I2C0DAT = I2CAddress;
break;

case (0x28):
I2C0CONSET = 0x10;
break;

default:
break;
}

I2C0CONCLR = 0x08;
VICVectAddr = 0x00000000;
}

void I2CTransferbyte (unsigned Addr, unsigned Data)
{
I2CAddress = Addr;
I2CData = Data;
I2C0CONCLR = 0x000000FF;
I2C0CONSET = 0x00000040;
I2C0CONSET = 0x00000020;
}

int main (void) {

VICVectCntl1 = 0x00000029;
VICVectAddr1 = (unsigned)I2CISR;
VICIntEnable = 0x00000200;

PINSEL0 = 0x50;
I2C0SCLH = 0x08;
I2C0SCLL = 0x08;

}

> Take a look at the WIZnet demo in the FreeRTOS.org download. This has an
> I2C link to a TCP/IP co-processor. LPC2106 rather than LPC2148, and GCC
> rather than Keil, but its just C code so not that dependent on the
> compiler.
>
> Regards,
> Richard.
>
> http://www.FreeRTOS.org
> for Cortex-M3, ARM7, ARM9, HCS12, H8S, MSP430
> Microblaze, Coldfire, AVR, x86, 8051 & PIC18 * * * *

The 2024 Embedded Online Conference