• AVR Freaks

Hot![SOLVED]PIC receive Problem, please help

Page: 123 > Showing page 1 of 3
Author
thunderboympm
Muhammed Rafeeq K
  • Total Posts : 32
  • Reward points : 0
  • Joined: 2007/10/09 02:49:07
  • Location: Kerala, India
  • Status: offline
2020/02/27 21:52:52 (permalink)
0

[SOLVED]PIC receive Problem, please help

hai,in a project, I am reading the return back from a GSM Module (SIM900A), the module is AE GSM MODULE. the problem is when I am connecting the GSM module through the ft232 module by serial GSM modem is working, and also my program is also OK, but when I am connecting to the AE GSM MODULE the program is not getting the return back. anyone has faced similar problems and can anyone give any clues.
post edited by thunderboympm - 2020/03/08 19:23:26
#1

49 Replies Related Threads

    ric
    Super Member
    • Total Posts : 26058
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC receive Problem, please help 2020/02/27 22:00:01 (permalink)
    +1 (1)
    thunderboympm
    ...
    when I am connecting the GSM module through the ft232 module by serial GSM modem is working,

    I guess you mean the module works ok if you connect it to your PC through a USB-serial adaptor.
     
    ...
     when I am connecting to the AE GSM MODULE the program is not getting the return back.

    When you connect it to what?
    You have not revealed what PIC you are using, how you have connected the GSM module to the PIC, or shown any of the PIC software you are using to receive the data.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/28 04:55:00 (permalink)
    0
    ric
    thunderboympm...when I am connecting the GSM module through the ft232 module by serial GSM modem is working,
    I guess you mean the module works ok if you connect it to your PC through a USB-serial adaptor. 
    ... when I am connecting to the AE GSM MODULE the program is not getting the return back.

    When you connect it to what?You have not revealed what PIC you are using, how you have connected the GSM module to the PIC, or shown any of the PIC software you are using to receive the data. 

    Sir,
    I am connecting GSM module to pic18f452 through serial port with board rate of 9600. I am Getting good results in pc when I am connecting to pc. But in pic I am getting OERR error. So I disable CREN and enabled after a NOP period. At that time my data getting lost.
    I am using mplabx and XC8 as compiler...
    #3
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/28 04:55:01 (permalink)
    0
    ric
    thunderboympm...when I am connecting the GSM module through the ft232 module by serial GSM modem is working,
    I guess you mean the module works ok if you connect it to your PC through a USB-serial adaptor. 
    ... when I am connecting to the AE GSM MODULE the program is not getting the return back.

    When you connect it to what?You have not revealed what PIC you are using, how you have connected the GSM module to the PIC, or shown any of the PIC software you are using to receive the data. 

    Sir,
    I am connecting GSM module to pic18f452 through serial port with board rate of 9600. I am Getting good results in pc when I am connecting to pc. But in pic I am getting OERR error. So I disable CREN and enabled after a NOP period. At that time my data getting lost.
    I am using mplabx and XC8 as compiler...
    #4
    katela
    Super Member
    • Total Posts : 1631
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/28 06:25:57 (permalink)
    +1 (1)
    What errors are you getting? Can you show the PIC code you are using to receive the data?
    It's difficult for anybody to guess what could be the problem when you can't provide enough relevant information.

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #5
    pcbbc
    Super Member
    • Total Posts : 1631
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: PIC receive Problem, please help 2020/02/28 06:42:04 (permalink)
    +3 (3)
    In the majority of these cases in the past the poster was not aware that the PIC receive buffer is only 2 bytes and with no built in flow control.  You have to implement the flow control signals in your code if you require it.
     
    So, when the module is sending data, their code is off doing something else (stuck in a loop sending for example).  As a result the received data very quickly overruns the 2 byte (1 buffered, 1 currently being received into the UART shift register) buffer and the results is an OERR.
     
    To handle synchronous bi-directional communications correctly almost certainly requires a ISR and a software receive buffer.  Ideally with some flow control logic.
     
    A PC serial to USB adapter has a much bigger internal buffer and implements end to end flow control.  It won't suffer these limitations.
     
    As others have commented - it's really hard to say if the OP doesn't present any code, or even reveal the device they are working with!
    #6
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/28 08:55:38 (permalink)
    0
    Sir, I am capturing a SMS from GSM module after giving the command at+cnmi=2,2,0,0,0
    I made an interrupt subroutine like this
    void __interrupt() ISR(void){
    GIE = 0;
    if(RCIF){
    RCIF = 0;
    GSMtemp = RCREG;
    if(GSMtemp == '+'){
    plusFlag = 1;
    GSMindex = 0;
    }
    if(plusFlag){
    GSMbuff[GSMindex] = GSMtemp;
    GSMindex ++;
    }
    if(GSMtemp == 'K')
    OKFlag = 1;
    if(OERR){
    CREN = 0;
    NOP();
    CREN = 1;
    }
    }
    GIE = 1;
    }
    As you said I am getting only two characters in correct format. After I am getting OERR error. What I want to do. The buffer size is 80.
    #7
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/28 08:56:42 (permalink)
    0
    katela
    What errors are you getting? Can you show the PIC code you are using to receive the data?It's difficult for anybody to guess what could be the problem when you can't provide enough relevant information.

    void __interrupt() ISR(void){
    GIE = 0;
    if(RCIF){
    RCIF = 0;
    GSMtemp = RCREG;
    if(GSMtemp == '+'){
    plusFlag = 1;
    GSMindex = 0;
    }
    if(plusFlag){
    GSMbuff[GSMindex] = GSMtemp;
    GSMindex ++;
    }
    if(GSMtemp == 'K')
    OKFlag = 1;
    if(OERR){
    CREN = 0;
    NOP();
    CREN = 1;
    }
    }
    GIE = 1;
    }
    This is my interrupt subroutine, what I need to do
    #8
    pcbbc
    Super Member
    • Total Posts : 1631
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: PIC receive Problem, please help 2020/02/28 09:57:08 (permalink)
    +4 (4)
    1. Do not modify GIE in an ISR - Ever.
    2. You cannot clear RCIF in software.  It is cleared automatically by reading RCREG.  Not a problem, but it is pointless.
    3. How is GSMbuff defined? You could well have a buffer overflow here.  You don't post all your code so we don't know.
    4. Just checking for "K" is a very bad way of checking for success - presumably OK?  Just saying...
    5. GIE=1 is probably your culprit.  Enabling interrupts in an ISR is even more a NO NO than disabling them.
    6. In my opinion this whole routine should be written.  The ONLY thing you should be doing in the ISR is checking for errors and reading from RCREG and placing in a circular buffer.  No checking of the actual data received.  That code all belongs in main where you can process it at your leisure.
    7. Probably you should check for OERR before you try reading.  Really not much point continuing if you have OERR.
    8. Other problems may exist elsewhere, but you don't show use the rest of your code so we don't know.
    9. Please place use [​code]//code tags[​/code] around your code when posting code here:
    //code tags

    post edited by pcbbc - 2020/02/28 09:59:09
    #9
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/28 10:41:14 (permalink)
    -1 (1)
    pcbbc
    3. How is GSMbuff defined? You could well have a buffer overflow here.  You don't post all your code so we don't know.


    unsigned char GSMbuff[80];

    #10
    ric
    Super Member
    • Total Posts : 26058
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC receive Problem, please help 2020/02/28 13:38:55 (permalink)
    0
    I don't know what you have done trying to post those images, but it is triggering lots of "Trojan Malware website" errors on my PC, for "meginaflight.com"
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/28 20:52:04 (permalink)
    0
    ric
    I don't know what you have done trying to post those images, but it is triggering lots of "Trojan Malware website" errors on my PC, for "meginaflight.com"
     


    I can't understand, what you are trying to inform...
    #12
    ric
    Super Member
    • Total Posts : 26058
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC receive Problem, please help 2020/02/29 00:01:06 (permalink)
    0
    You tried to paste eight images into post#10
    They all have URLs similar to:
    https://meginaflight.com/metric/?mid=&wid=52641&sid=&tid=8791&rid=LOADED&custom1=www.microchip.com&custom2=%2Fforums%2Fm1129931.aspx&t=1582911487410"

     
    That triggers a virus warning from Malwarebytes on my PC.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #13
    pcbbc
    Super Member
    • Total Posts : 1631
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: PIC receive Problem, please help 2020/02/29 00:39:19 (permalink)
    0
    No links here, but then I’m viewing on iOS.
    But it therefore looks unlikely they were inserted by the OP.
    #14
    PStechPaul
    Super Member
    • Total Posts : 2555
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: online
    Re: PIC receive Problem, please help 2020/02/29 00:46:19 (permalink)
    +1 (1)
    When I googled that domain, I found a hit that said it was hiding in Firefox.
     
    https://www.theforumsa.co...-com-HIDING-IN-FIREFOX

     
    #15
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/29 08:54:02 (permalink)
    0
    thunderboympm
    ricI don't know what you have done trying to post those images, but it is triggering lots of "Trojan Malware website" errors on my PC, for "meginaflight.com" 

    I can't understand, what you are trying to inform...

    If it is my fault, I am extremely sorry. But it is not me, I can't see anything...
    #16
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/29 08:55:30 (permalink)
    -1 (1)
    pcbbc
    1. Do not modify GIE in an ISR - Ever.2. You cannot clear RCIF in software.  It is cleared automatically by reading RCREG.  Not a problem, but it is pointless.3. How is GSMbuff defined? You could well have a buffer overflow here.  You don't post all your code so we don't know.4. Just checking for "K" is a very bad way of checking for success - presumably OK?  Just saying...5. GIE=1 is probably your culprit.  Enabling interrupts in an ISR is even more a NO NO than disabling them.6. In my opinion this whole routine should be written.  The ONLY thing you should be doing in the ISR is checking for errors and reading from RCREG and placing in a circular buffer.  No checking of the actual data received.  That code all belongs in main where you can process it at your leisure.7. Probably you should check for OERR before you try reading.  Really not much point continuing if you have OERR.8. Other problems may exist elsewhere, but you don't show use the rest of your code so we don't know.9. Please place use [​code]//code tags[​/code] around your code when posting code here:
    //code tags


    Sir,
    Even though I did it I am getting same result.
    #17
    PStechPaul
    Super Member
    • Total Posts : 2555
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: online
    Re: PIC receive Problem, please help 2020/02/29 11:38:36 (permalink)
    +1 (1)
    You did NOT do it (post your code), so of course you will get the same result (no help from us).

     
    #18
    thunderboympm
    Muhammed Rafeeq K
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2007/10/09 02:49:07
    • Location: Kerala, India
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/29 18:31:53 (permalink)
    0
    PStechPaul
    You did NOT do it (post your code), so of course you will get the same result (no help from us).

    void __interrupt() ISR(void){

    if(PIR1bits.RCIF){
    if(RCSTAbits.OERR){
    RCSTAbits.CREN = 0;
    NOP();
    RCSTAbits.CREN = 1;
    }
    GSMbuff[GSMindex] = RCREG;
    GSMindex++;
    gsmFlag = 1;
    }
    }

    This is my interrupt subroutine.
       while(1){
    if(gsmFlag){
    while(1){
    if(GSMbuff[GSMindex - 1] == EOD){
    gsmFlag = 0;
    break;
    }
    if(GSMindex >= MAX_BUF_LEN)
    break;
    STAT = !STAT;
    }

    This is the code snippet in my main program
    I have EOD as '*' and MAX_BUF_LEN as 200 .
    GSMbuff is a char array of size of 200
    #19
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11673
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: PIC receive Problem, please help 2020/02/29 19:37:43 (permalink)
    +1 (1)
    What baud rate are you using?  What is the clock frequency of your PIC?  Are you disabling receive interrupts in your main code for some reason?  With a reasonable baud and clock speed, it is impossible to get an overrun error, and there is no point slowing down your ISR to check for it if your code is designed correctly.
    post edited by jtemples - 2020/02/29 19:56:38
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5