Reply by samjith_wasim July 25, 20092009-07-25
--- In l..., Ananda Regmi wrote:
>
> I checked manual for LPC23xx and I could not find a control register
named
> VICVectCntl19. I think you need to look at what are you setting in
your
> code?
> I suggest you to set that register thinking control registers in
LPC23xx
> would be similar as in LPC2106 but it does not seem to be the case.
>
> Other things you should look at are:
>
> 1. How have you configured your I2C interface. Master or Slave.
> 2. If it is configured as Master, you need to initiate the
transmission
> process by first setting the STA(start) bit in I2CONSET register.
> 3. If it is configured as Slave, is the master sending any data?
>
> Here's the snippets of my code that worked for me on LPC2106. I have
it
> configured as Master and I initiate data transmission by calling *
> ItwoCinterface_start_master_transmit* function.
>
> // I2C interface constants
> #define I2CONSET_AA 0x00000004
> #define I2CONSET_SI 0x00000008
> #define I2CONSET_STO 0x00000010
> #define I2CONSET_STA 0x00000020
> #define I2CONSET_I2EN 0x00000040
> #define I2CONCLR_AAC 0x00000004
> #define I2CONCLR_SIC 0x00000008
> #define I2CONCLR_STAC 0x00000020
> #define I2CONCLR_I2ENC 0x00000040
>
> void ItwoCinterface_init(void)
> {
> // I2C Interface initialization
> I2C_I2CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC |
> I2CONCLR_I2ENC;
>
> // I2C_I2SCLL = 100; // 300 Khz
> // I2C_I2SCLH = 100;
>
> I2C_I2SCLL = 200; // 150 Khz
> I2C_I2SCLH = 200;
>
> PCB_PINSEL0 = PCB_PINSEL0 & PINSEL0_02_MASK;
> PCB_PINSEL0 = PCB_PINSEL0 & PINSEL0_03_MASK;
>
> PCB_PINSEL0 = PCB_PINSEL0 | PINSEL0_02_SCL | PINSEL0_03_SDA;
>
> // Set this interrupt as IRQ not FIQ
> VICIntSelect = VICIntSelect & ~I2C_INTERRUPT;
>
> VICVectAddr2 = (unsigned long)ItwoCinterface_ISR;
> VICVectCntl2 = THIS_VIRQ_IS_ENABLED |
> I2C_INTERRUPT;
> VICIntEnable = ENABLE_I2C_INTERRUPT;
>
> I2C_I2CONSET = I2CONSET_I2EN;
>
> i2c_interface.read_or_write = I2_READ;
> i2c_interface.data_received_count = 0;
> i2c_interface.data_ready = 0;
> return;
> }
> void ItwoCinterface_start_master_transmit(ItwoCinterface * this)
> {
> this->command_to_send = 0x00; // Internally timed integration
completes
> every 100 msec.
> this->read_or_write = I2_WRITE;
> I2C_I2CONSET = I2CONSET_STA;
> }
>
> void ItwoCinterface_start_master_receive(ItwoCinterface * this)
> {
> this->read_or_write = I2_READ;
> I2C_I2CONSET = I2CONSET_STA;
> }
> Hope that helps.
>
> On Fri, Jul 24, 2009 at 12:08 AM, samjith_wasim samjithwasim@...wrote:
>
> >
> >
> > I have worked with Timer Interrupts and found it absolutely easy and
> > working Perfectly.The same i am following up with I2C Interrupts.
> >
> > As you told i have also configured VicVentCntl Register .
> > but still i am not getting irq function invoked.
> >
> > VICVectAddr19 = (unsigned long)ReadCapKey0;
> > VICVectCntl19 = 1;
> > VICIntEnable = (1 << 19);
> >
> > __irq void ReadCapKey0(void)
> > {
> > ......................
> > ................
> > ....
> >
> > VICVectAddr = 0 // for ACK Interrupt
> >
> > }
> >
> >
> >
>
>

An Engineer's Guide to the LPC2100 Series

Reply by Ananda Regmi July 24, 20092009-07-24
I checked manual for LPC23xx and I could not find a control register named
VICVectCntl19. I think you need to look at what are you setting in your
code?
I suggest you to set that register thinking control registers in LPC23xx
would be similar as in LPC2106 but it does not seem to be the case.

Other things you should look at are:

1. How have you configured your I2C interface. Master or Slave.
2. If it is configured as Master, you need to initiate the transmission
process by first setting the STA(start) bit in I2CONSET register.
3. If it is configured as Slave, is the master sending any data?

Here's the snippets of my code that worked for me on LPC2106. I have it
configured as Master and I initiate data transmission by calling *
ItwoCinterface_start_master_transmit* function.

// I2C interface constants
#define I2CONSET_AA 0x00000004
#define I2CONSET_SI 0x00000008
#define I2CONSET_STO 0x00000010
#define I2CONSET_STA 0x00000020
#define I2CONSET_I2EN 0x00000040
#define I2CONCLR_AAC 0x00000004
#define I2CONCLR_SIC 0x00000008
#define I2CONCLR_STAC 0x00000020
#define I2CONCLR_I2ENC 0x00000040

void ItwoCinterface_init(void)
{
// I2C Interface initialization
I2C_I2CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC |
I2CONCLR_I2ENC;

// I2C_I2SCLL = 100; // 300 Khz
// I2C_I2SCLH = 100;

I2C_I2SCLL = 200; // 150 Khz
I2C_I2SCLH = 200;

PCB_PINSEL0 = PCB_PINSEL0 & PINSEL0_02_MASK;
PCB_PINSEL0 = PCB_PINSEL0 & PINSEL0_03_MASK;

PCB_PINSEL0 = PCB_PINSEL0 | PINSEL0_02_SCL | PINSEL0_03_SDA;

// Set this interrupt as IRQ not FIQ
VICIntSelect = VICIntSelect & ~I2C_INTERRUPT;

VICVectAddr2 = (unsigned long)ItwoCinterface_ISR;
VICVectCntl2 = THIS_VIRQ_IS_ENABLED |
I2C_INTERRUPT;
VICIntEnable = ENABLE_I2C_INTERRUPT;

I2C_I2CONSET = I2CONSET_I2EN;

i2c_interface.read_or_write = I2_READ;
i2c_interface.data_received_count = 0;
i2c_interface.data_ready = 0;
return;
}
void ItwoCinterface_start_master_transmit(ItwoCinterface * this)
{
this->command_to_send = 0x00; // Internally timed integration completes
every 100 msec.
this->read_or_write = I2_WRITE;
I2C_I2CONSET = I2CONSET_STA;
}

void ItwoCinterface_start_master_receive(ItwoCinterface * this)
{
this->read_or_write = I2_READ;
I2C_I2CONSET = I2CONSET_STA;
}
Hope that helps.

On Fri, Jul 24, 2009 at 12:08 AM, samjith_wasim wrote:

> I have worked with Timer Interrupts and found it absolutely easy and
> working Perfectly.The same i am following up with I2C Interrupts.
>
> As you told i have also configured VicVentCntl Register .
> but still i am not getting irq function invoked.
>
> VICVectAddr19 = (unsigned long)ReadCapKey0;
> VICVectCntl19 = 1;
> VICIntEnable = (1 << 19);
>
> __irq void ReadCapKey0(void)
> {
> ......................
> ................
> ....
>
> VICVectAddr = 0 // for ACK Interrupt
>
> }
>
>
>


Reply by samjith_wasim July 24, 20092009-07-24
I have worked with Timer Interrupts and found it absolutely easy and working Perfectly.The same i am following up with I2C Interrupts.

As you told i have also configured VicVentCntl Register .
but still i am not getting irq function invoked.

VICVectAddr19 = (unsigned long)ReadCapKey0;
VICVectCntl19 = 1;
VICIntEnable = (1 << 19);

__irq void ReadCapKey0(void)
{
......................
................
....
VICVectAddr = 0 // for ACK Interrupt
}

Reply by Ananda Regmi July 23, 20092009-07-23
>From your description it seems like you forgot to initialize VIC vector
control register. For my LPC2106 it's represented as: VICVectCntl.

You can find an example of I2C implementation using interrupt here:

http://www.nxp.com/acrobat_download/applicationnotes/AN10369_1.pdf

I would recommend you first make simpler interrupt working. For example a
timer interrupt is easy to implement. After you have that working you know
for sure your interrupt setups work. Then you can try I2C in interrupt
mode.

Best Wishes,
Ananda

On Thu, Jul 23, 2009 at 8:48 AM, samjith_wasim wrote:

> I was able to configure and work with I2C interface in LPC2368 using
> Polling Method.There was no problem with the polling method.
>
> Now i am forced to use I2C using Interrupt Routines for Real-Time
> Applications. I configured the following registers for enabling ISR , when i
> tried simulating the program , the VIC Address, VIC Enable Bit and VIC
> Priority are setting up properly.But the function where i used ISR is not
> invoking , i was not able to solve out where is the problem.Is there any
> more additional registers i should configure other than these ?
>
> 1. VICEnableInt = (1<<19); //for setting I2C1 Interrupt
> 2. VICAddress19 = (unsigned long)Read_IRQHandler; // Interrupt Addr
> 3. VICPriority19 = 1;
>
> I have defined the function like this __irq void Read_IRQHandler();
>
> Any other Interrupt Configuration have I Left Off ???
>
> Please Bounce as soon as possible Guys...
>
> Regards,
> Samjith
>
>
>


Reply by samjith_wasim July 23, 20092009-07-23
I was able to configure and work with I2C interface in LPC2368 using Polling Method.There was no problem with the polling method.

Now i am forced to use I2C using Interrupt Routines for Real-Time Applications. I configured the following registers for enabling ISR , when i tried simulating the program , the VIC Address, VIC Enable Bit and VIC Priority are setting up properly.But the function where i used ISR is not invoking , i was not able to solve out where is the problem.Is there any more additional registers i should configure other than these ?

1. VICEnableInt = (1<<19); //for setting I2C1 Interrupt
2. VICAddress19 = (unsigned long)Read_IRQHandler; // Interrupt Addr
3. VICPriority19 = 1;

I have defined the function like this __irq void Read_IRQHandler();

Any other Interrupt Configuration have I Left Off ???

Please Bounce as soon as possible Guys...

Regards,
Samjith