EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Cannot receive sms from gsm mobile

Cannot receive sms from gsm mobile

|

Microcontroller › AVR › Cannot receive sms from gsm mobile

  • This topic has 1 reply, 2 voices, and was last updated 6 years, 11 months ago by Hari Prasaath K.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 18, 2016 at 1:08 pm #4378
    Bakhtiar
    Participant

    Dear Concern,

    I am facing problem to receive sms . Below is my code . Please help  me .

    in main block:


    int main (void)
    {
        uint8_t x = 0;

        board_init();
        
        cpu_irq_enable();
        
        DDRB = 0x7f;
        lcd_initialise();
        usart_setup();
        
      
        
        initialize_mdm();
        
        while (1)
        {
            msg = strstr(rx_data,"RING");
            if (!(strncmp(msg,"RING",4)))
            {
                msg = strstr(rx_data,"1714094407");
                if (!(strncmp(msg,"1714094407",10)))
                {
                    lcd_command(0x01);lcd_display("Calling:");lcd_command(0xc0);
                    while (x<10){lcd_data(*(msg+x));x++;}x=0;delay_s(1);
                    tx_data("ATH");serial_enter();delay_s(1);
                    lcd_command(0x01);lcd_display("Call Rejected");
                }
                clear_rx_data();
            }
           
            msg = strstr(rx_data,"CMTI");
            if (!(strncmp(msg,"CMTI",4)))
            {
                lcd_command(0x01);lcd_display("SMS Received");            
                tx_data("AT+CMGR=");tx_char(*(msg+11));serial_enter();delay_s(1);
                clear_rx_data();
            }
        }
    }

     

    in uart setup:


    #define RXD PD0
    #define TXD PD1

    uint16_t rx_count=0;
    char rx_data[255];

    void usart_setup(void);
    void tx_data(char *data_string);
    void tx_char(char);
    void clear_rx_data(void);
    void serial_enter(void);

    void usart_setup()
    {
    //    Making TXD as output pin
        DDRD |= 1<<TXD;
    //    Making RXD as input pin
        DDRD &= ~(1<<RXD);
    //    Baud Rate is 9600 selected with 0.2% error
        UBRRL = 0x0c;
    //    Asynchronous operation, Parity mode disabled, 1-stop-bit and 8-bit character size
        UCSRC |= 1<<URSEL;
        UCSRC |= 1<<UCSZ1|1<<UCSZ0;
    //    Enabling Double Transmission rate
        UCSRA |= 1<<U2X;
    //    Enabling Receive complete interrupt, transmitter and receiver
        UCSRB |= 1<<RXCIE|1<<TXEN|1<<RXEN;
    }

    void tx_data(char *data_string)
    {
        uint16_t i=0;
        
        while (data_string!=0)
        {
            //    Wait until UDRE goes high
            while (!(UCSRA & 0x20));
            //    Place the data byte
            UDR = data_string
    ;
            //    Wait until TXC flag goes high
            while (!(UCSRA & 0x40));
            //    Clear TXC flag by writing '1' to its bit position
            UCSRA |= 0x40;
            i++;
        }
    }

    void tx_char(char data_byte)
    {
        //    Wait until UDRE goes high
        while (!(UCSRA & 0x20));
        //    Place the data byte
        UDR = data_byte;
        //    Wait until TXC flag goes high
        while (!(UCSRA & 0x40));
        //    Clear TXC flag by writing '1' to its bit position
        UCSRA |= 0x40;
    }

    void clear_rx_data()
    {
        uint16_t clear=0;
        
        while (clear<rx_count)
        {
            rx_data[clear] = 0;
            clear++;
        }        
        rx_count=0;
    }

    void serial_enter()
    {
        tx_char(0x0d);                                                                        // Carriage return<CR>
        delay_ms(50);
        tx_char(0x0a);                                                                        // Line feed<LF>
        delay_ms(50);
    }

    ISR(USART_RXC_vect)
    {
        
        //    Store the received byte in variable
        rx_data[rx_count] = UDR;
        rx_count++;
    }

     

    should i miss any steps.

     

     

    July 23, 2018 at 6:51 am #14872
    Hari Prasaath K
    Participant

    Check with the below link for brief description of code

    ablab.in/receiving-an-incoming-call-in-sim800-gsm-gprs-modem-with-avr-atmega32-microcontroller/

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Fixing board, Easy question HEX SCHMITT July 10, 2025
  • Can I make two inputs from one?? July 10, 2025
  • Display TFT ST7789 (OshonSoft Basic). July 9, 2025
  • Home Smoke detectors are all Beeping Batteries are not dead.??? July 9, 2025
  • The Analog Gods Hate Me July 9, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise