arunraj1984
Junior Member level 2
Hello,
I am using the keil microvision 4. and the code is below.
after configure the I2CONSET the status byte is changing to 0x08 but the code does not entering the ISR.
is there any mistake in initialize the interrupts
Thankyou
I am using the keil microvision 4. and the code is below.
after configure the I2CONSET the status byte is changing to 0x08 but the code does not entering the ISR.
is there any mistake in initialize the interrupts
Thankyou
Code:
#include <LPC210x.H>
void ISR(void)__irq
{
switch (I2STAT) // Read result code and switch to next action
{
case ( 0x08): // Start bit
I2CONCLR = 0x28; // Clear start bit
I2DAT = 0x80; // Send address and
// write bit
break;
case (0x18): // Slave address+W, ACK
I2DAT = 72; // Write data to tx register
break;
case (0x20): // Slave address +W, Not ACK
I2DAT = 80; // Resend address and write bit
break;
case (0x28): // Data sent, Ack
I2CONSET = 0x10; // Stop condition
break;
default :
break;
}
I2CONCLR = 0x08; // Clear I2C interrupt flag
VICVectAddr = 0x00000000; // Clear interrupt in
}
void init()
{
PINSEL0 = 0X50;
I2SCLH = 0X0C;
I2SCLL = 0X0D;
I2ADR = 0x40;
VICIntEnClr = 0xffffffff;
VICVectAddr = 0;
VICIntSelect = 0;
VICIntEnable = 0x200; // ENABLING i2c INTERRUPT
VICVectCntl0 = 0x29;
VICVectAddr0 = (unsigned int)ISR;
}
int main()
{
init();
I2CONSET = 0x64;
while(1)
{
IODIR = 0x0f;
IOSET = 0x0f;
IOCLR = 0x0f;
}
}