This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem in GSM modem response handling using interrupt method of LPC2148 UART0

Actually i am getting problem while trying to receive the incoming sms from gsm modem to micro controller

controller-lpc2148
Uart- UART0 //Cpu clock-60 Mhz (using PLL 12Mhz*5=60Mhz)
VPB -15mhz //9600 baud rate ,8 bit data,1 stop bit,no parity
Enabled interrupt-Rx0

  • What seems to be the issue? Is there are problem with the code you wrote? A problem debugging the code and/or hardware? Or that you expect someone to perform the coding task for you?

  • Thanks and sorry for your reply and my late reply sir.Actually i am getting problem in code side not in hardware side .But the same code working perfectly in Pic micro controller.I can't receive the data from receiver buffer properly.I don't think so whether I am ok or not ok with this following Interrupt isr..Iam the new one to keil ARM .Please give me the direction.

    This is code is, char s1[28], s2[28],DATA0_RECEIVED;//global declaration

    void myUart0_ISR(void)__irq { long int regVal; regVal = U0IIR; // read the current value in U0's Interrupt Register if((U0IIR&RDA)) { unsigned char dataa; dataa=U0RBR; if(dataa!=0x0A) { s1[count++]=dataa; } else { s1[count++]='\0'; count=0; for(i=0; s1[i]!='\0';i++) { s2[i]=s1[i]; } s2[i]='\0'; DATA0_RECEIVED=1; } VICVectAddr = 0x00; // The ISR has finished! } } /** Baud calc DLL=(pclk/(16*9600)) pclk derived from Cclk by using VPBDIV (in datasheet APBDIV) **/

    void UART0_INIT() { PINSEL0 |= 0x00000005; //p0.15 and p0.7 as GPIO P0.1=RXD P0.0=TXD U0LCR=0x83;//(1<<0)|(1<<1)|(0<<2)|(1<<7);//data,stop,parity bit as well DLAB=1 befor do calc Bdrte U0DLL=97;//15mhz//for 30 mhz0xC3;//110;//BDrte U0DLM=0; U0LCR&=~(1<<7);//DLAB=0 before enable uart interrupt as well for U0RBR,U0THR buffers U0FCR = 0x01; //clear the buffer U0IER=0x1; //Uart Rx itrpt Enable VICIntSelect=0x00;//selct as IRQ VICVectCntl0=6|(1<<5);//IRqslot enable(5,)interrupt no 4,//slot0 has high and slot 15 has low priority VICVectAddr0=(unsigned)myUart0_ISR; VICIntEnable=(1<<6); }

  • How about reposting the code but with the proper tags as displayed directly above the message input box. Right now, it's very hard to read with no line breaks or indentation...

  • Sorry for the last post sir,

    //Once gsm got any sms it will sent to the uC,have to receive that and show it in the 16x2 LCD

    char s1[28], s2[28],DATA0_RECEIVED;//DATA0_RECEIved is flag

    void myUart0_ISR(void)__irq

    {

    long int regVal;

    regVal = U0IIR; // read the current value in U0's Interrupt Register

    if((U0IIR&RDA))

    {

    unsigned char dataa;

    dataa=U0RBR;

    if(dataa!=0x0A)

    {

    s1[count++]=dataa; }

    else

    {

    s1[count++]='\0';

    count=0;

    for(i=0; s1[i]!='\0';i++)

    {

    s2[i]=s1[i];

    }

    s2[i]='\0';

    DATA0_RECEIVED=1;

    }

    VICVectAddr = 0x00; // The ISR has finished!

    } }

    void UART0_INIT() {

    PINSEL0 |= 0x00000005; //p0.15 and p0.7 as GPIO P0.1=RXD P0.0=TXD

    U0LCR=0x83;//data,stop,parity bit as well DLAB=1 befor do calc Bdrte

    U0DLL=97;//15mhz -BDrte

    U0DLM=0;

    //U0FDR=(MULVAL<<4)|DIVADDVAL;//Fraction for Prescale her it is no need

    U0LCR&=~(1<<7);//DLAB=0 before enable uart interrupt as well for U0RBR,U0THR buffers

    U0FCR = 0x01; //clear the buffer

    U0IER=0x1; //Uart Rx itrpt Enable

    VICIntSelect=0x00;//selct as IRQ

    VICVectCntl0=6|(1<<5);//IRqslot enable(5,)interrupt no 4,//slot0 has high and slot 15 has low priority

    VICVectAddr0=(unsigned)myUart0_ISR;

    VICIntEnable=(1<<6);

    }

  • You really do not like to use the proper tags for source code...

    Notice the difference with source code posted using the intended tags?

    #include <stdio>
    
    int main(void) {
        printf("Hello World!\n");
        return 0;
    }
    

    By the way - you shouldn't read twice from U0IIR since reading from registers isn't identical to reading from normal RAM - that's why you have the "regVal" variable.

  • Thanks for your reply sir,

    Actually i seen in a tutorial in that code for timer0 before to check overflow in isr,they read the register by a variable.That's why i used that variable(regval).But sir,i removed that variable and checked ,i am getting the same problem.If you allow me i will update here my main() code.

  • Have you read the chapter about UART0 in the processor user manual? You don't seem to check if the least significant bit of U0IIR is zero. And it's good to care about both RDA and CTI since both are enabled by the same bit in U0IER.

    And you should read U0IIR at the end of your initialization routine.

  • Sir, I read the processor manual for UART0,I didn't check the CTI as well the 0'th bit of U0IIR. When Gsm getting incoming message means with in that fraction it will send the full string in to Rx buffer as well i don't know where & how to check these things in the isr function and one more thing is that if i connecting lke RFID reader,gps modules means i can able to receive and read the full string without any problem.Then how it could be possible sir?

  • By the way - I think you should consider looking at the ring buffer implementation that Keil has available. It's way better than copying a full text line when you see a line break - you don't want big loops inside an ISR.

  • Sir, ring buffer..? i have no prevoius experiance with ring buffer.So i have to google about ring buffer and also why & where do you refer me this ring buffer to implent?

    To check buffer register,

    "if(dataa!=0x0A)"

    or

    for(i=0; s1[i]!='\0';i++)

    {

    s2[i]=s1[i];

    }
    Please clarify me also I am the new one to keil.So please guide me to do the ring buffer implementation

  • Sorry, can't afford the time to guide you. But Google is your friend. There is more than enough information available. Just make sure to read a bit more carefully than you read the posting instructions for source code - details tends to be important.

  • Sorry for the mistakes in last post.I try to re write the code using ring buffer sir.Could i able to use this ring buffer concept in to ISR.?Is that possible

  • Most definitely - as clearly described in quite a number of articles about the use of ring buffers. They are so popular just because they work well with interrupts or with multiple threads. So you haven't located the Keil LPC2100 UART sample code yet?