Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I2C intrfacing with lpc2148

Status
Not open for further replies.

jalpa koyani

Newbie level 1
Newbie level 1
Joined
Mar 15, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
9

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<lpc214x.h>
void i2c_start()
{
  I2C0CONSET=1<<5;         // start falg bit 1 
}
void i2c_stop()
{
  I2C0CONSET=1<<4;         // stop falg bit 1 
}
void i2c_init()
{
  //for master transmitter mode
    I2C0CONSET=1<<6;         //i2c enble I2EN bit
  I2C0SCLH=80;
    I2C0SCLL=70;
}
int main()
{
    PINSEL0=(1<<4) |  (1<<6) ;     //for SCL and SDA functiong
    IODIR0= (1<<2) | (1<<3);       // for making SDA and SCL output
     I2C0CONCLR=0x6C;
  i2c_init();
     i2c_start();
    while(I2C0STAT != 0x08);
    I2C0DAT = 0xA0;
    while(I2C0STAT != 0x28);
    I2C0DAT = 0x00;
    while(I2C0STAT != 0x28);
    I2C0DAT = 0x00;
    while(I2C0STAT != 0x28);
    I2C0DAT = 12;
    while(I2C0STAT != 0x28);
    i2c_stop();
    I2C0CONCLR=(1<<2) |(1<<3) |(1<<5)|(1<<6);
    while(1);
}


is there ant problem in this code? it cant run
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top