Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] help on serial programming with 8051. i got black box character.. :)

Status
Not open for further replies.
you can receive a complete sms of 120 characters , but you should receive it in an array of suitable size.. and then compare the string in the array with the string you have stored in program and take necessary action....
 
check this sample program.. bit lengthy , but see only sms receive part...
 

Attachments

  • New Folder.rar
    5.4 KB · Views: 97
check this sample program.. bit lengthy , but see only sms receive part...

wow! thanks so much I will check the example code... :)

---------- Post added at 06:40 ---------- Previous post was at 06:27 ----------

hmmmm you are right it lengthy.. I'll try to gasp part I needed... thanks so much..
 

help. about my se t290.. I used this as my modem.. i tried AT commands and it works well but when after i deleted the msg in the inbox I cannot locate the memory location of the new msg in the inbox now..

---------- Post added at 09:30 ---------- Previous post was at 09:19 ----------

okay it's now solved.. the default storage if phone memory so i need to select storage first before reading.. :)
AT+CPMS="SM" //sim memory
AT+CPMS="ME" //phone memory..
 

can you check this.. its home automation using sms..

just unzip this and try it on keil....
 

Attachments

  • home automation.rar
    38.9 KB · Views: 108
Code:
void gsm_receive()
{
while(rx_data()!='+');    // wait till + symbol comes through UART as the sender number will have a + in the beginning of mobile no.
		while(rx_data()!='\"');   
		for(count=0;count<13;count++)   //if + is there then wait for read 12 digit mobile number including 91  so +91xxx is read.
      	{
       		phone_num[count]=rx_data();   // store every digit of phone number received into array.
        }
    	phone_num[count]='\0';
    	while(rx_data()!='\n');                             //new line
		for(count=0;count<5;count++)        // message to be received is a max of 5 characters
     	{
      		message[count]=rx_data();            // receive the sms and store in message array
      		if(message[count]=='\r')                  
			break;
     	}
}
 
Code:
void gsm_receive()
{
while(rx_data()!='+');    // wait till + symbol comes through UART as the sender number will have a + in the beginning of mobile no.
		while(rx_data()!='\"');   
		for(count=0;count<13;count++)   //if + is there then wait for read 12 digit mobile number including 91  so +91xxx is read.
      	{
       		phone_num[count]=rx_data();   // store every digit of phone number received into array.
        }
    	phone_num[count]='\0';
    	while(rx_data()!='\n');                             //new line
		for(count=0;count<5;count++)        // message to be received is a max of 5 characters
     	{
      		message[count]=rx_data();            // receive the sms and store in message array
      		if(message[count]=='\r')                  
			break;
     	}
}



hi.. thanks.. its more clearer example.. I try go through with this.. thanks so much

---------- Post added at 08:27 ---------- Previous post was at 08:00 ----------

hi,, from the code above how this slash works

while(rx_data()!='\"');


---------- Post added at 10:17 ---------- Previous post was at 08:27 ----------

another question.. after I transmit "AT" we know that modem will reply "OK" but why i do not receive any response from the modem or any echo?? pls check this code.




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void main()
{
 
   unsigned char volatile ch[10], i=0;
   serial_init();
   lcd_init();
 
   while(1)
   {
     serial_send('A');
     lcd_data(serial_read());
     serial_send('T');
     lcd_data(serial_read());
     enter();
 
     while(i<6)
     ch[i++]=serial_read();
 
     if(ch[5]=='K')
     lcd_str(" AT OK  ");
   }
 
}

 
Last edited:

i think the problem is the proteus compim.. I cannot communicate to the physical port..

---------- Post added at 13:00 ---------- Previous post was at 12:34 ----------

**broken link removed**

guys.. hehe thank G0D it works... i dont know what happen but it just works... I can now communicate to physical port with proteus... :)
 

Is all your problem solved with all above posts or struck anywhere????????

not solved yet.. hehe

maybe I will get stuck soon along with the codding but this progrees is very importand because I can now actully communicating with the physical hardware.. hehe thanks yar!!
 

hi what's the reason why I cannot catch the "OK" reply of the modem?

but when I tried to interface my code to hyperterminal and type OK it can identify that Im typing OK word

unsigned char ch[10],i=0;

serial_send('A');
serial_send('T');
enter();

while ((ch[i++] = serial_read()) != 'K');
if(ch[i-1]=='K')
{
lcd_str("Modem OK",0x80);
delay_ms(500);
}
 

guys, i write a simple code to received a string from uart and I successfully received a 5 character string i entered from the hyperterminal but how did it happen I cannot get the echo response from the modem?

the modem is replying my command "AT" because I seen it in virtual terminal.. the problem is I the code below connot read it and send it back..




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <REG51.H>
#include "lcd.h"
#include "uart.h"
char buff[10],i;
void serial_readstr()
{
   
 
   for(i=0; i<6; i++)
  buff[i] = serial_read();
  
}
 
 
void main()
{
  char x;
  serial_init();
  lcd_init();
 
  serial_send('A');
  serial_send('T');
  enter();
 
  while(1)
  {
    
    serial_readstr();
    lcd_str("hi",0xc0);
    while(x<5)
    serial_send(buff[x++]);
  }
}



---------- Post added at 06:17 ---------- Previous post was at 06:06 ----------

as your can see in the photo below when I send command AT the modem replies "OK"... I want to received that okay and transmit again...... 1 thing weird is that if I used hyperterminal I can get the received data and transmit it back..

**broken link removed**
 

I did not get what you said...
you get OK response from modem, what is the next step you want the output to be. do you want to send ok again back to hyperterminal from controller???
you can send next at command upon receiving the OK response.......
what is the purpose of sending OK again back to hyperterminal.............
 
I did not get what you said...
you get OK response from modem, what is the next step you want the output to be. do you want to send ok again back to hyperterminal from controller???
you can send next at command upon receiving the OK response.......
what is the purpose of sending OK again back to hyperterminal.............


sorry.... I will post cleare question later.. im experimenting on my data cable now. something weird happens.. :)
 

**broken link removed**

thank.. I can now read the response after hardware handshaking... hehe

i destroyed the cable and i made my own with max232..... thanks guys

---------- Post added at 11:38 ---------- Previous post was at 10:22 ----------

**broken link removed**

update: I can now read the response then display to LCD after initialization..
 
  • Like
Reactions: MRAMA

    MRAMA

    Points: 2
    Helpful Answer Positive Rating
hi ckshivaram,

I just finished this project.. its now working perfectly... Im very happy... thanks so much to your help...
 

im done with the project.. thanks

i used serial interrupt to read the CMTI response for the msg location then read, parse then delete.. the project is now working... thanks so much..

i will mark this thread solved after few hours... thanks guys...

---------- Post added at 18:00 ---------- Previous post was at 17:58 ----------

now its ready to accept sms commands and at the same time can monitor the remaining I/O ports of the controller..

**broken link removed**
 
  • Like
Reactions: MRAMA

    MRAMA

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top