• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

GSM Module - Receive String Code


Active Member
I want to detect whether it is a call or a SMS on a SIM800L module. I wrote my own ISR based method. but sometimes its messed up not receiving the correct characters.
Is there any proper way to receive them?

            org            0004h
            movwf       W_Temp          ; save off current W register contents
            movf        STATUS,W        ; move status register into W register
            movwf        S_Temp
            bcf            STATUS,RP0        ; B0
Check_UART    btfss        PIR1,RCIF        ; Is it a Recieve interrupt?
            goto        ISR_Exit       
            movf        RCREG,W            ; read the buffer
            andlw        b'01111111'
            movwf        RX_DATA            ; load to a temperory register

Start_RX    movf        RX_DATA,W
            xorlw        .13                ; CR?
            btfsc        STATUS,Z
            goto        ISR_Exit
            movf        RX_DATA,W
            xorlw        .10                ; LF?
            btfsc        STATUS,Z
            goto        ISR_Exit
            movf        RX_DATA,W
            btfsc        Flag_Register,String_CALL
            goto        Do_CALL
            btfsc        Flag_Register,String_SMS
            goto        Do_SMS
Check_Call    xorlw        'R'
            btfss        STATUS,Z
            goto        Check_SMS
            movf        RX_DATA,W
            goto        Do_CALL
Check_SMS    movf        RX_DATA,W
;+CMT: "+44128740842","","19/14/05,14:24:45+22"
Do_SMS        bsf            Flag_Register,String_SMS
            btfss        SMS_Register,0
            goto        SMS_State_1
            btfss        SMS_Register,1
            goto        SMS_State_2
            btfss        SMS_Register,2
            goto        SMS_State_3
            btfss        SMS_Register,3
            goto        SMS_State_4
            btfss        SMS_Register,4
            goto        SMS_State_5
            btfss        SMS_Register,5
            goto        SMS_State_6
            btfss        SMS_Register,6
            goto        SMS_State_7
            btfss        SMS_Register,7
            goto        SMS_State_8
            goto        String_Exit
SMS_State_1    xorlw        '+'
            btfss        STATUS,Z
            goto        String_Exit
            bsf            SMS_Register,0
            goto        ISR_Exit           
SMS_State_2    xorlw        'C'
            btfss        STATUS,Z
            goto        String_Exit
            bsf            SMS_Register,1
            goto        ISR_Exit           
Do_CALL        bsf            Flag_Register,String_CALL
            btfss        Call_Register,0
            goto        State_1
            btfss        Call_Register,1
            goto        State_2
            btfss        Call_Register,2
            goto        State_3
            btfss        Call_Register,3
            goto        State_4
            btfss        Call_Register,4
            goto        State_5
            btfss        Call_Register,5
            goto        State_6
            goto        ISR_Exit
State_1        xorlw        'R'
            btfss        STATUS,Z
            goto        String_Exit
            bsf            Call_Register,0
            goto        ISR_Exit           

State_2        xorlw        'I'
            btfss        STATUS,Z
            goto        String_Exit
            bsf            Call_Register,1
            goto        ISR_Exit

Latest threads

EE World Online Articles