Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to send sms to my gsm modem - SIM300 V7.01.

How to send AT Command serially? I mean how and where to insert the AT Commands in the serial program given below:

C++
#include <reg51.h>
void SerTx(unsigned char);
void main(void){
TMOD=0x20; //use Timer 1, mode 2
TH1=0xFD; //9600 baud rate
SCON=0x50;
TR1=1; //start timer
while (1) {
SerTx(‘Y’);
SerTx(‘E’);
SerTx(‘S’);
}
}
void SerTx(unsigned char x){
SBUF=x; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}

If the program is wrong, kindly give me the suitable solution for this.
My project submission is in 5 days. Please help me out in this regard.

[edit] added code tags[/edit]
Posted
Updated 22-Apr-12 12:36pm
v2
Comments
Andy411 23-Apr-12 2:07am    
Well, sad but true, I've never realy programmed a microcontroller, but I would recognize your code as µC code. You need the documentation for your µC to understand how to work with the build in(?) serial interface. Try google for the type of µC you're using.

BTW: If it's homework, this is the wrong place to ask....
Sandeep Mewara 23-Apr-12 2:32am    
This does sounds like not his 'own' work. A copy-paste may be and now modification/correction needed!
M Prajwal 24-Apr-12 4:28am    
the code i've written here is from a microcontroller book authored by mazidi.i want help in programming i.e. inserting AT commands in this program !!!
M Prajwal 24-Apr-12 4:33am    
i want to insert the AT commands in the program above, so that the commands are transmitted serially into GSM modem. guidance needed in programming !!
the uC i'm using is AT89c51 with flash memory, and the GSM modem is sim300 v 7.03 and v 7.01!
Sandeep Mewara 23-Apr-12 2:32am    
Here is what is expected of enquirers:
1. TRY first what you want to do!
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.

1 solution

This looks like code for an 8051 microcontroller. First read the documentation or a tutorial (Google came up with this[^] site)

I no longer remember how to configure the serial port, you'll have to look up the appropriate register settings.
Other than that, your code looks OK, try calling SerTx with each character of the AT command sequence.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900