CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

[Help] Receive respone AT message from module SIM548C

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Delfy_Coltech



Joined: 25 Nov 2009
Posts: 27
Location: Vietnam

View user's profile Send private message Visit poster's website

[Help] Receive respone AT message from module SIM548C
PostPosted: Thu Nov 10, 2011 8:14 pm     Reply with quote

Hi everybody!

I am doing a small project that uses dsPIC and module SIM548C.
I want to interface my PIC with that module.

I use UART1 (baud=19200) port of PIC to do that. You know that, when an AT command is sent to SIM module. It will respond with a string.

I want to receive all string responses from module SIM. How do I do this?

This is my code
Code:

#INT_RDA
void RDA_isr(void){
 
  gsm_buf[i]=fgetc(GSM_STR);
  i++;
  if(i>MSG_LENGTH)
  {
    i = 0;
  }
}


But when I use:
Code:
printf(lcd_putc, "%s", gsm_buf);
There is only some strange characters on LCD. (I can receive a full correct string).

Thanks!
_________________
-------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
-------------------------------------------------
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Fri Nov 11, 2011 3:01 am     Reply with quote

Several different possible things.

First, a 'string' in C, requires a null terminator. Without this, when you print your buffer, you will get loads of garbage displayed, as the print walks through memory, printing things, until it accidentally hits a '0'.
Normally strings from something like a modem, will have a line feed at the end of the line!. So check for this in your code, and if it is seen, add the terminating '0' to the buffer, and prematurely reset 'i'.
Also, remember the buffer should be _longer_ than the longest string you expect, by at least the character for the terminator...

Second, are you sure the module you are using is talking at 19200bps. Some require an initialisation to be sent when they first wake up (typically three line feeds), to set the baud rate to use. Unless this is happening, you module may be talking at the wrong rate. I think the default for the module you describe, is 115200bps, not 19200bps....

Third are you sure of your wiring?. You do realise that the module you have 'talks' RS232, _not_ TTL levels like the PIC, so a MAX232 or similar buffer is required between the PIC and this unit.

Best Wishes
Delfy_Coltech



Joined: 25 Nov 2009
Posts: 27
Location: Vietnam

View user's profile Send private message Visit poster's website

Disscussion...
PostPosted: Fri Nov 11, 2011 4:13 am     Reply with quote

Hi Mr. Ttelmah!
The third one, This modem can connect directly to microcontroller.
The second one, It also supports autobauding, so we don't need to setup baudrate for it. But I will try to setup a fix baudrate.
And the first one, I know that, I have written code to receive line feed and carriage return.

I think, 3 comments are very useful! I will review all

Thanks alot! Very Happy
_________________
-------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
-------------------------------------------------
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group