- Mon Jun 21, 2010 2:51 am
#103510
Hello all,
i have written code for rx interrupt,but it's not entering into interrupt function,anyone can tell me where i am doing mistake.
void InitSerial (void)
{
VPBDIV = 0x00;
PLL0CFG = 0x24;
PLL0FEED = 0x55;
PLL0CON = 0x03;
PINSEL0 = 0x00050000; // Enable RxD0 and TxD0
U1LCR = 0x83; // 8 bits,no Parity,1 Stop bit
U1DLL = 97; // 9600 Baud @ 12MHz Clock
U1DLM=0x00;
U1LCR = 0x03; // DLAB = 0
U1FCR=0x07;
U1IIR = 0xC1; // FIFO Enable, No pend. Int
U1FDR = 0x00000010;
VICProtection = 0; // disable protection
//VICIntEnClear = 0xFFFFFFFF; // disable all interruptions
VICIntSelect &= 0xFFFFFF7F; // IRQ -uart1
VICVectAddr1 = (unsigned long)uart1; // Set interrupt vector in 1
VICVectCntl0 = 0x20 | 7; // use it for Serial 0 Int */
VICIntEnable |= 0x00000080;
U1IER |= 0x04;
}
int main (void)
{
//char arr[10];
//static int i;
IODIR1 = 0x00FF0000;
InitSerial();
}
int ReceiveChar (void)
{
while (!(U1LSR & 0x01));
return (U1RBR);
}
int SendChar (int ch)
{
while (!(U1LSR & 0x20));
if(ch == '\n')
return (U1THR = CR);
else
return (U1THR = ch);
}
__irq void uart1(void)
{
unsigned int i;
unsigned char ch;
unsigned char RecivedString[50];
ch = ReceiveChar();
if(ch != CR)
{
RecivedString[i] = ch;
i++;
}
else
{
SendChar('\n');
RecivedString[i] = 0x00;
i = 0;
}
VICVectAddr = 0;
}
i have written code for rx interrupt,but it's not entering into interrupt function,anyone can tell me where i am doing mistake.
void InitSerial (void)
{
VPBDIV = 0x00;
PLL0CFG = 0x24;
PLL0FEED = 0x55;
PLL0CON = 0x03;
PINSEL0 = 0x00050000; // Enable RxD0 and TxD0
U1LCR = 0x83; // 8 bits,no Parity,1 Stop bit
U1DLL = 97; // 9600 Baud @ 12MHz Clock
U1DLM=0x00;
U1LCR = 0x03; // DLAB = 0
U1FCR=0x07;
U1IIR = 0xC1; // FIFO Enable, No pend. Int
U1FDR = 0x00000010;
VICProtection = 0; // disable protection
//VICIntEnClear = 0xFFFFFFFF; // disable all interruptions
VICIntSelect &= 0xFFFFFF7F; // IRQ -uart1
VICVectAddr1 = (unsigned long)uart1; // Set interrupt vector in 1
VICVectCntl0 = 0x20 | 7; // use it for Serial 0 Int */
VICIntEnable |= 0x00000080;
U1IER |= 0x04;
}
int main (void)
{
//char arr[10];
//static int i;
IODIR1 = 0x00FF0000;
InitSerial();
}
int ReceiveChar (void)
{
while (!(U1LSR & 0x01));
return (U1RBR);
}
int SendChar (int ch)
{
while (!(U1LSR & 0x20));
if(ch == '\n')
return (U1THR = CR);
else
return (U1THR = ch);
}
__irq void uart1(void)
{
unsigned int i;
unsigned char ch;
unsigned char RecivedString[50];
ch = ReceiveChar();
if(ch != CR)
{
RecivedString[i] = ch;
i++;
}
else
{
SendChar('\n');
RecivedString[i] = 0x00;
i = 0;
}
VICVectAddr = 0;
}