Ravindrakant Jha
Junior Member level 2
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 #include <LPC214X.H> #define RDR 0x01 //receiver data ready #define THRE 0x20//enable transmit interrupt #define RDA 0x04 //receive data available on U0IIR extern unsigned char msg[50]; unsigned char ch; unsigned int count,i; void check(unsigned char); void serial_receive(void) __attribute__ ((interrupt("IRQ"))); void sleep_mode() { PCON = 0x01; } void serial_init(unsigned int baudrate) { PINSEL0=0X00; PINSEL0=0X05; VICIntSelect |=(1<<6);//selecting uart 0 interrupt VICIntEnable |=(1<<6);//enalbling uart 0 interrupt U0LCR=0X83; //latch open U0DLL=(unsigned)((3000000)/(16*baudrate))%256; //baud rate set U0DLM=(unsigned)((3000000)/(16*baudrate))/256; U0LCR=0X03; // latch close U0FCR=0X01; // fifo control register U0IER=0X00000001; // VICVectAddr1 = (unsigned long int)serial_receive; // VICVectCntl1 = 0x20 | 6; //(alternatively (1<<5) can also be used in place of 0X20 VICVectAddr1 = (unsigned)serial_receive; //Pointer Interrupt Function (ISR) VICVectCntl1 = 0x20 | 6; VICIntEnable |= (1<<6); //Enable Uart0 interrupt , 6th bit=1 } void serial_receive(void) //receive { do { ch = U0RBR; check(ch); } while(!(U0LSR&RDR)); VICVectAddr = 0x00; } void serial_transmit(char t) //transmit { U0THR=t; // transmit holding register while(!(U0LSR&0X20)); } void send_string(char *str) //to send a string { while(*str!='\0') serial_transmit(*str++); } void check(unsigned char c) { count=0; i=0; if(c==0X0a || c==0X0d) count++; else { msg[i]=c; i++; } }
to constantly monitor what i am receiving through my gsm i have declared an receive interrupt using UART0 in LPC2148.but when i build the program in keil it shows an warning
" attribute "interrupt" ignored".
and if i declare interrupt with the qualifier it shows an error
" declaration is incompatible with "void serial_receive(void)__irq".
I am unable to find mistake in my code.
Last edited by a moderator: