Sign in

username:

password:



Not a member?

Search lpc2000



Search tips

Subscribe to lpc2000



lpc2000 by Keywords

2106 | ADC | ARM7 | Atmel | Bootloader | CAN | CrossStudio | CrossWorks | DDS | ECos | Ethernet | ETM | FIFO | FLASH | FPGA | GCC | GDB | GNU | GNUARM | GPIO | I2C | IAP | IAR | JTAG | Kickstart | LCD | Linux | LPC | LPC-E2294 | LPC2000 | LPC2100 | LPC2104 | Lpc2106 | Lpc210x | LPC2114 | LPC2119 | LPC2124 | LPC2129 | Lpc2138 | LPC213x | LPC21xx | LPC2210 | LPC2212 | LPC2214 | LPC2292 | LPC2294 | LPC2xxx | LPC3128 | MCB2100 | Olimex | Philips | PWM | Rowley | RTC | RTOS | SPI | SSP | UART | UART0 | UART1 | ULINK | USB | Watchdog | Wiggler


Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | LPC2000 | I2C experience with CrossStudio and LPC2129


Advertise Here

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

I2C experience with CrossStudio and LPC2129 - neptunus1000 - Mar 30 11:10:00 2005


Hello,

I'm trying to get the I2C bus working on a LPC2129 witj CrossStudio.
I'm already working on it for 2 day's. But no result. Is there some one
how can help my?

Thanks





(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )


Re: I2C experience with CrossStudio and LPC2129 - neptunus1000 - Mar 30 15:54:00 2005


--- In lpc2000@lpc2..., "neptunus1000" <roykrikke@h...> wrote:
>
> Hello,
>
> I'm trying to get the I2C bus working on a LPC2129 with
CrossStudio.
> I'm already working on it for 2 day's. But no result. Is there some
one
> who can help my?
>
> Thanks

De Clock line is not working. The Data line is working. I'm confused.

The code I'm using:

#define STA 0x20
#define SIC 0x08
#define SI 0x08
#define STO 0x10
#define STAC 0x20
#define AA 0x04

class I2C{
private:

public:
I2C(void);
void delay(int);
void InitI2C(void);
void SendSlaveAdress(int addressSlave);
int ReadOnI2C(void);
void WriteOnI2C(int data);
};

I2C::I2C(void){

}
void I2C::delay(int d){
for(; d; --d){
asm volatile ("nop");
}
}

void I2C::InitI2C(void){
// Set pinouts as scl and sda
PINSEL0 |= 0x00000050;
PINSEL0 &= 0xFFFFFF5F;

I2SCLL = 400;
I2SCLH = 400;
I2CONCLR = 0xFF;
delay(10);

I2CONSET = 0x00000040; //Active Master Mode on I2C bus
} void I2C::SendSlaveAdress(int addressSlave){
if(!(addressSlave & 0x01)){ //test if it's a master adress
//while(I2C_I2STAT!=0xF8);
I2CONSET = STA;
while(I2STAT != 0x08); //Set and wait the start

I2DAT = addressSlave; // Charge slave Address
I2CONCLR = SIC | STAC; // Clear i2c interrupt bit to
send the data
while(I2STAT != 0x18 && !(I2CONSET & SI));
//wait the ACK
} else { //it's a slave adress
I2CONSET = STA;
I2CONCLR = SIC;
while(I2STAT != 0x10 && !(I2CONSET & SI)); //Set
and wait the start
I2DAT = addressSlave; // Charge slave Address
I2CONCLR = SIC | STAC; // Clear i2c interrupt bit to
send the data
while(I2STAT != 0x40 && !(I2CONSET & SI));
//wait the ACK
}
} int ReadOnI2C(void){
I2CONCLR = SIC;//ACK from the master
while(I2STAT != 0x50 && !(I2CONSET&SI)); //wait the data
// Read the data...
return I2DAT;
}

void WriteOnI2C(int data){
I2DAT = data; // Charge Data
I2CONCLR = SIC; // Clear i2c interrupt bit to send the
data
while(I2STAT != 0x28 && !(I2CONSET & SI)); //wait the ACK
}




(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )