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 / not getting accepected answer

not getting accepected answer

|

Microcontroller › AVR › not getting accepected answer

  • This topic has 2 replies, 2 voices, and was last updated 12 years ago by Shashank Rao.C.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • June 13, 2013 at 11:29 am #2481
    Shashank Rao.C
    Participant

    hi friends,

             I stucked in new problem. I programed ATmega16 with following code.

     

     

    #define F_CPU 12000000UL      // set CPU freq.
    #define USART_BAUDRATE 9600
    #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) – 1)
    #include<avr/io.h>
    #include<util/delay.h>
    #include<string.h>

    #define PUMP_CONTROL PORTC // MOTOR CONTROL PIN.

    void usart_init();
    void usart_putch(unsigned char send);
    unsigned int usart_getch();
    void usart_message(unsigned char *var);
    void usart_recivemsg(unsigned char *msg);
    void send_message(unsigned char *message_send);

    unsigned char msg[50] = “”;
    unsigned char on[50]=”PUMP ON”;
    unsigned char off[50]=”PUMP OFF”;

    int main(void)
    {
    while(1)
    {
    usart_init();                    // initialize UART port.

    //usart_message(“ATrn”);          // Sent AT into USART.
    //_delay_ms(10000);
    //usart_message(“AT+CMGF=1rn”);   //Select mesage mode in text mode.
    //_delay_ms(1000);
    //usart_message(“AT+CPMS=’SM’rn”); // Select the mesage memory.
    //_delay_ms(1000);
    //usart_message(“AT+CMGR=1rn”);   // Read the message from index 1.
    //_delay_ms(3000);
    usart_recivemsg(msg);
    //compare_string();
    //final_result=fresult;
    //usart_message(“AT+CMGD=1rn”);

    if(strcmp(on,msg) == 0)
    {

    PUMP_CONTROL=0X03;
    send_message(“PUMP IS ON”);
    //init_LCD();

    }

    else if(strcmp(off,msg) == 0)
    {
    PUMP_CONTROL=0x04;
    send_message(“PUMP IS OFF.”);
    }

    else
    {
    send_message(“INVALID MESSAGE FORMAT”);      //DEFAULT MESAGE
    }

    }
    usart_message(“AT+CMGD=1rn”);   //delete the messsage

    }

    //***********************************FUNCTIONS**********************************************//

    void usart_init()                                // Function to initialize USART.
    {
    UCSRB |= (1 << RXEN) | (1 << TXEN);
    // Turn on the transmission and reception circuitry
    UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 <<
    UCSZ1);
    // Use 8-bit character sizes
    UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value..
    // into the low byte of the UBRR register
    UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
    // into the high byte of the UBRR register
    }

    void usart_putch(unsigned char send)                   //
    {
    while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..
    // for more data to be
    //written to it
    UDR = send; // Send the byte
    }

    unsigned int usart_getch()         //FUNCTION TO RECIVE A CHARATER.
    {
    while ((UCSRA & (1 << RXC)) == 0);
    // Do nothing until data have been
    //received and is ready to be read from UDR
    return UDR; // return the byte
    }

    void usart_message(unsigned char *var)    
    {
    int h;
    while(*var)
    usart_putch(*var++);
    for(h=0;h<=200;h++); //sends characters one by one till string ends
    }

    void usart_recivemsg(unsigned char *msg)         //Function to recive a msg.
    //value of the string in pointer *msg
    {
    int i=0;
    while(msg!=’’)
    //go on till the NULL character in the string
    {
    usart_getch(msg
    );
    //sending data on LCD byte by byte
    i++;
    }
    return;
    }

    void send_message(unsigned char *message_send)             //FUCTION TO SEND MESSAGE.
    {
     usart_message(“ATrn”);          // Sent AT into USART.
           _delay_ms(10000);
            usart_message(“AT+CMGF=1rn”);   //Select mesage mode in text mode.
           _delay_ms(1000);
            usart_message(“AT+CPMS=’SM’rn”); // Select the mesage memory.
           _delay_ms(1000);
            usart_message(“AT+CMGS=”+91xxxxxxxxxx”rn”);   // SEND the message.
            usart_message(message_send);
        usart_putch(0x1A);                        //CTRL+Z to send the mesage
    return;
    }

     

     

     

     

    For checking I connected it to pc using rs232. In ubuntu i use cutecom tool for hyperterminal.

    As i connect this to pc in hyperteminal window some values are repaeting itself.

    Values are like bellow.

     

    Qxabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxebx8aXxb9xe7Cxd4|:xc4Qxebx8aWjxe7@SJL6ZIJJb@xb1x1cx19Z8x1cx01@9jx17x05S9x92Wxd4x1cxd9L8xabxc4Qxebx8aWJuIxb1xfcQxeb

     

    I don’t know what is this. But I dont get accepected answer. Please help me

    June 13, 2013 at 11:57 am #9961
    AJISH ALFRED
    Participant

    Hi,

    Suggest you to check the baud rate, number of bits, number of start and stop bits etc. in the cutecome. Disable the hardware handshaking. Also check the serial cable which you are using. 

    Is your circuit OK, please post your circuit diagram also.

    June 13, 2013 at 12:31 pm #9963
    Shashank Rao.C
    Participant

    Sir, 

            hand shake is disabled. Iam sending screen shot of cutecom.wysiwyg_imageupload:9008:height=375,width=513

     

    circuit is very similar to an article published in this website only  with very little change.

     

     

    change is that i am using port c also for device ctrl.

     

     

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

RSS Recent Posts

  • Simple LED Analog Clock Idea July 7, 2025
  • The Analog Gods Hate Me July 7, 2025
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz July 7, 2025
  • PIC KIT 3 not able to program dsPIC July 7, 2025
  • Parts required for a personal project July 6, 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