• 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.

AT Commands from uC

Status
Not open for further replies.

premkumar9

Member
Hi,
I could send SMS through a GSM moule by giving AT commands through Hyperterminal and serial port of my PC. Now I want give AT commands from my uC. How can I give (Ctrl Z) and <CR> from uC?
 

kpatz

New Member
Does your uC have a serial interface? Hook it up to your GSM module and send ASCII characters for the AT commands.

Ctrl-Z = 26 (0x1A) - to figure out a Ctrl character, subtract 64 (0x40) from the character's ASCII value. Or just count letters of the alphabet: Ctrl-A = 1, Ctrl-B = 2 ... Ctrl-Z = 26.

<CR> = 13 (0xD), also known as Ctrl-M
<LF> = 10 (0xA), also known as Ctrl-J
 
Last edited:

premkumar9

Member
Does your uC have a serial interface? Hook it up to your GSM module and send ASCII characters for the AT commands.

Ctrl-Z = 26 (0x1A) - to figure out a Ctrl character, subtract 64 (0x40) from the character's ASCII value. Or just count letters of the alphabet: Ctrl-A = 1, Ctrl-B = 2 ... Ctrl-Z = 26.

<CR> = 13 (0xD), also known as Ctrl-M
<LF> = 10 (0xA), also known as Ctrl-J
Thank you. My uC have serial interface. In this case I am sending my text message for SMS as a character string. So to add Ctrl-Z at the end, is it enough to add 0x1A as the last byte of the string?
 

premkumar9

Member
Now I am trying to send SMS by giving AT commands through the serial port of my uC(AT89S52). The GSM module I am using is Wavecom 2686. I write the code in C and using the tool KEIL for compiling.
Can anybody please give some links to samples codes which I can refer to (I am also trying to locate something useful.
 

premkumar9

Member
uC to PC

Can I connect the serial port of uC(RXD,TXD and GND) to serial port of Laptop and use Hyperterminal for communication between the two?
 

premkumar9

Member
Using Hyperterminal

I give below my program for sending a string through the serial port.It is working and giving the text in the serial window. But when I gave it through the RS232 interface IC (HIN 232) to the serial port of PC and tried to see the string with Hyperterminal, I am not getting the string displayed. Could it be any problem in my program?
Any guidance will be highly appreciated
#include <At89x52.h>
#include <stdio.h>
void init(void);
void main(void)
{
init();


while(1)
{
printf("This is a trial message\n");
}

}


void init(void)
{
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD = 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0xfd;
TL1 = 0xfd; /* TH1: reload value for 9600 baud @ 11.0592MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1;
TL0 = 0x00;
TH0 = 0x00;

}
 

Gayan Soyza

Active Member
premkumar9 its very hard to understand your problem by the way you type.

Serial port is available in the PC side (not in the microcontroller).The UART is available in the microcontroller.Can you use the two words highlighted & tell us the problem.
 

premkumar9

Member
premkumar9 its very hard to understand your problem by the way you type.

Serial port is available in the PC side (not in the microcontroller).The UART is available in the microcontroller.Can you use the two words highlighted & tell us the problem.
I give below my program for sending a string through the UART.It is working and giving the text in the serial window(I mean during debugging using KEIL tool. When I run the program using the debugger it is displaying the text in the serial window of the debugger). But when I gave it through the RS232 interface IC (HIN 232) to the serial port of PC (that is UART of the uC is connected to the serial port of PC through a RS232 converter IC HIN 232) and tried to see the string with Hyperterminal, I am not getting the string displayed. Here I have used RXD,TXD and GND connections only. My serial port (COM2)of PC and hyperterminal are tested separately with a different card and they are working. So what could be the probable reasons?
Is it clear now?:)
 

Gayan Soyza

Active Member
Now I understood a bit. You have simulated via your programmer. That’s why I was wondering how you connected your UART directly into your PC serial port.

Are you sure about your max 232 hardware? Remove your RX, TX inputs in the MAX & short those two pins. Now type in the HyperTerminal. You must see the letter you type.

Can you check what I have mentioned?

BTW I don’t like Microsoft HyperTerminal. You can use “Tera Term Terminal” software for simulating.
 

premkumar9

Member
Now I understood a bit. You have simulated via your programmer. That’s why I was wondering how you connected your UART directly into your PC serial port.

Are you sure about your max 232 hardware? Remove your RX, TX inputs in the MAX & short those two pins. Now type in the HyperTerminal. You must see the letter you type.

Can you check what I have mentioned?

BTW I don’t like Microsoft HyperTerminal. You can use “Tera Term Terminal” software for simulating.
Actually my PC does not have a RS232 port. It has only USB ports. So I used a USB to serial converter to connect my PC USB port to the UART.
In this condition I shorted RXD,TXD and checked as you said. But I am not getting the letters I typed.
But my COM2 (USB) and USB to serial connector are working with another device.
 

futz

Active Member
Actually my PC does not have a RS232 port. It has only USB ports.
Check your mainboard manual. Lots of mainboards (not all, of course) still have serial header pins on the board. They just don't bother to wire them to the back of the box anymore. You can either buy the cable with DB9 connector on a slot cover at a computer store (good luck finding one these days), or you could dig through a computer graveyard and scoop one out of an old computer. The old ones ALL had those serial connectors. Common as dirt in old computers.
 

premkumar9

Member
it worked

It worked. There was some problem in initializing the module. When the baud rate of module is changed to uC baud rate, it worked.
 

premkumar9

Member
Does your uC have a serial interface? Hook it up to your GSM module and send ASCII characters for the AT commands.

Ctrl-Z = 26 (0x1A) - to figure out a Ctrl character, subtract 64 (0x40) from the character's ASCII value. Or just count letters of the alphabet: Ctrl-A = 1, Ctrl-B = 2 ... Ctrl-Z = 26.

<CR> = 13 (0xD), also known as Ctrl-M
<LF> = 10 (0xA), also known as Ctrl-J
I have to read the string data coming to UART from another module.I want to skip all data in the first line and read the second line only. So I programmed my uC to read the contents coming after 0x0d which represents <CR>. But it never detects 0x0d. When I programmed to detect other characters, it worked. My question is what logic I can use to read the contents from the second line only (in hyper terminal, I see my required data coming in the second line). Also is it possible to display the control characters also in the hyperterminal so that I can check whether 0x0d is the last character coming in a line.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top