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.

interfacing gsm sim300 with PIC18f4550 ( RX & TX ) probem ..

Status
Not open for further replies.

Jan De

Newbie level 4
Joined
May 7, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
46
HI

I want to receive and send SMS from microcontroller using GSM sim300

the problem is that I'm not sure which pins are RX & TX
I've attached the picture of my GSM pins
please help me :(


DSC_0439.JPG
 

you have the datasheet of this kit?
Apparently the TX and RX pins are marked on the board:
TXD-RXD-PC and PC.
hope this helps.
 

you have the datasheet of this kit?
Apparently the TX and RX pins are marked on the board:
TXD-RXD-PC and PC.
hope this helps.


thank u for replying
I have the datasheet but I didn't get it
here is the pins diagram, please give it a look
which of them can I connect directly with the PIC rx & tx pins !

SIM300_AUTO_Translated1.gif
 

Hello Jan De,
To connect directly to your pic you need to find the pins with the MCU-TXD or T1OUT description, and the other should have the following description MCU-RXD or R1IN.
You can see the connections in the block where it is written Two level converter module.
hope this helps.
come back here and tell me if you enjoyed some results.;-)
 

Hello Jan De,
To connect directly to your pic you need to find the pins with the MCU-TXD or T1OUT description, and the other should have the following description MCU-RXD or R1IN.
You can see the connections in the block where it is written Two level converter module.
hope this helps.
come back here and tell me if you enjoyed some results.;-)

I found these terms written on the board ( RMCU) & ( TMCU ) in the first picture
but how can I count the pins to know what exactly the number of the pins
because each term has 2 pins in front of it ..

I'm sorry but this is my first time to use this type of modems
do I have to use max232 if the direct pins doesn't work ?
 

If you observe, you can see an inscription on the side of each set of pins. In the picture you attached, you can see P2, P3 and P4. For example, looking at the description P2 on the board you will see that there is a number 6 on the side, this number corresponds to the pin that is on your side, therefore the pin side of the P2 registration will be number 5, this way you discover a pattern of group numbers pins. Easy is not it?
I hope it helps you. And feel free to ask again.:)
 
  • Like
Reactions: Jan De

    Jan De

    Points: 2
    Helpful Answer Positive Rating
If you observe, you can see an inscription on the side of each set of pins. In the picture you attached, you can see P2, P3 and P4. For example, looking at the description P2 on the board you will see that there is a number 6 on the side, this number corresponds to the pin that is on your side, therefore the pin side of the P2 registration will be number 5, this way you discover a pattern of group numbers pins. Easy is not it?
I hope it helps you. And feel free to ask again.:)

yes its very easy ! thanks alot

now I've tried the mcu_txd & mcu_rxd directly with rx & tx pins of PIC18
but nothing happend :(

this is the code that I'm using, maybe the problem is in the code! otherwise I'm going to try it with max232


Code:
  // this code is for sending and receiving a SMS + sending back  (my code)


#include<p18f4550.h>
#include<delays.h>
#define FREQ 12000000
#define baud 9600
#define spbrg_value (((FREQ/64)/baud)-1)

#pragma config PLLDIV = 3
#pragma config CPUDIV = OSC1_PLL2
#pragma config FOSC = HS
#pragma config MCLRE = ON
#pragma config WDT = OFF, DEBUG = OFF
#pragma config LVP = OFF
#pragma config PWRT = OFF 
#pragma config PBADEN = OFF
#pragma config ICPRT = OFF
 
 //    defining LCD PORT   
 //---------------------------------
#define ldata PORTD    
#define rs PORTCbits.RC0
#define rw PORTCbits.RC1
#define en PORTCbits.RC2
#define send PORTBbits.RB1 
#define rec PORTBbits.RB2


 //Defining the LCD commands
//------------------------------------------
void lcdcmd(unsigned char value)
{
ldata = value;
rs = 0;
rw = 0;
en = 1;
Delay100TCYx( 30 );
en = 0;
}

 
//Defining the LCD display
//------------------------------------------
void lcddata(unsigned char value)
{
ldata = value;
rs = 1;
rw = 0;
en = 1;
Delay100TCYx( 30 );
en = 0;
}


// LCD initialization 
// ------------------------------

void lcd_ini()
{
lcdcmd(0x38);   //LCD matrix
Delay10KTCYx( 75 );
lcdcmd(0x0E);   //Blink curser
Delay10KTCYx( 4 );
lcdcmd(0x01);   //Clear LCD
Delay10KTCYx( 4 );
lcdcmd(0x06);     //increment curser
Delay10KTCYx( 4 );
lcdcmd(0x80); //start at firs line, first position
Delay10KTCYx( 4 );
}



// define serial communication ( receiving data from GPS)
//---------------------------------------
unsigned char rx_data(void); //receiving data function
void tx_data(unsigned char serial_data);     // Transmit data function
 
void display( unsigned char array[], int size); // to display any string on LCD
void transmit( unsigned char array2[], int size2); // to send any string to TX pin

unsigned char ch=0;
int i=0,j,k;
unsigned char welcome[]=" Welcome ";
unsigned char choice[]="Send or receive? "; 
unsigned char sending[]=" Sending .. ";
unsigned char waiting[]=" Waiting for SMS";
unsigned char sms_received[]=" SMS Received ";
unsigned char sending_back[]=" Sending Back: Hello";
unsigned char double_qoutes[]="\""; // to print "
unsigned char sms_send[]="AT+CMGS=";
unsigned char sms_format[]="AT+CMGF=1\r"; // TEXT mode
unsigned char sms_write[]="AT+CMGS=\"xxxxxxxxxx\"\r";  // 10-Digit Mobile Number
unsigned char sms[]="Hello\r";
unsigned char sms_report[]="SMS Sent...";
unsigned char sms_indication[]="AT+CNMI=1,2,0,0,0\r";
unsigned char phone_number[10];
unsigned char stringArray[46]; //to store the received sms information
unsigned char text[2]; // to store the text message
unsigned char sms_terminate=0x1A;
unsigned char enter=0x0D;
 
 

void main()
{
  
TRISD = 0;  //Set it output for the LCD
TRISCbits.RC0 = 0; //Set it output for RS
TRISCbits.RC1 = 0; //Set it output for RW
TRISCbits.RC2 = 0; //Set it output for en
TRISCbits.RC6 = 0; //TX pin set as output
TRISCbits.RC7 = 1; //RX pin set as input
TRISBbits.RB1 = 1; // To send an SMS
TRISBbits.RB2= 1; // To Receive an SMS

// serial communicatin configuration 

SPBRG=spbrg_value; //Fill SPBRG register to set the baud rate
RCSTAbits.SPEN=1; // To activate serial port (Tx and Rx pins)
RCSTAbits.CREN=1; // to enable continous receiving
TXSTA=0x24; // To enable transmition & low baud rate + 8-bits
 
   
   lcd_ini();

  Delay10KTCYx( 250);

        display( welcome, sizeof(welcome));
         Delay10KTCYx( 250);
         Delay10KTCYx( 250);
         Delay10KTCYx( 250);
       
 
           
   while(1)
   {      
      lcdcmd(0x01);
      lcdcmd(0x80);
      Delay10KTCYx( 250);
      display( choice, sizeof(choice));
        Delay10KTCYx( 250);
       

          if(send==1)
            {
             lcdcmd(0x01);
             lcdcmd(0x80);
             Delay10KTCYx( 250);
             display(sending, sizeof(sending));
             Delay10KTCYx( 250);
             transmit(sms_format, sizeof(sms_format)); // to set the mode 
             Delay10KTCYx( 250);

             transmit(sms_write, sizeof(sms_write));
             Delay10KTCYx( 250);
             transmit(sms, sizeof(sms));   
             tx_data(sms_terminate);
              lcdcmd(0x01);
             lcdcmd(0x80);
             Delay10KTCYx( 250);
             display(sms_report, sizeof(sms_report));
             Delay10KTCYx( 250);
             Delay10KTCYx( 250);
              
               }  
       
        if(rec==1)
          {
          lcdcmd(0x01);
             lcdcmd(0x80);
             Delay10KTCYx( 250);
             display(waiting, sizeof(waiting));
             transmit(sms_format, sizeof(sms_format)); // to set the mode 
             transmit(sms_indication, sizeof(sms_indication)); 
            
   
        ch = rx_data();       
        if(ch == '+')
        {
            do
            {
                ch = rx_data();
            }while(ch != '\n');

            i = 0;

            do
            {
                text[i++] = rx_data();
            }while(i < 2 );
                
        }

              lcdcmd(0x01);
             lcdcmd(0x80);
             Delay10KTCYx( 250);
             display(text, sizeof(text));
             Delay10KTCYx( 250);
             Delay10KTCYx( 250);  
    

            
          
    



        }
} //end while1


}// end main function

//------ methods ---------

unsigned char rx_data(void)
{
while(PIR1bits.RCIF==0); // Wait until RCIF gets low
return RCREG; // Store data in Reception register
}

void tx_data(unsigned char serial_data)      // Transmit data function
{
   TXREG=serial_data;
   while(PIR1bits.TXIF==0);
}
 
void display( unsigned char array[], int size)
{
    for(i=0; i<size; i++)
      {
         lcddata(array[i]);
      }
}

void transmit( unsigned char array2[], int size2)
{
    for(i=0; i<size2; i++)
     {
       tx_data(array2[i]);
     }
}
 

OK! You wrote a very complete code. I recommend that you first do a simple test sending and response, just to check if the communication is working. You have a logical analyzer? Or if you already did these tests, and make sure the problem is on the sign, I recommend that you use the max232.
When you do please let me know about your results.:wink:
 
  • Like
Reactions: Jan De

    Jan De

    Points: 2
    Helpful Answer Positive Rating
OK! You wrote a very complete code. I recommend that you first do a simple test sending and response, just to check if the communication is working. You have a logical analyzer? Or if you already did these tests, and make sure the problem is on the sign, I recommend that you use the max232.
When you do please let me know about your results.:wink:

hi ..
thank u again for replying
I've connected the RMCU with the PIC18 RX
and TMCU with PIC TX
no results again ..

for testing I don't have logical analyzer, but I've tested the rx and tx pins of the microcontroller using LEDs .

I want to mention that my modem is working with 12v power supply
and my microcontroller works with 5v , does this have anything to do with this problem ?

also I'm using now 4Mhz crystal
and I fill these registers with values below :
SPBRG= 25;
TXSTA=0x24;

is there anything I can try ?
 

I think the problem is not related to the supply kit, think it's just an error in the configuration, which u will find easily and I'll help you.which PIC you are using? and what baud rate?
 

I think the problem is not related to the supply kit, think it's just an error in the configuration, which u will find easily and I'll help you.which PIC you are using? and what baud rate?

PIC18f4550
and the baud rate is : 9600
 

Hello,
The formula that u are using the #define SPBRG not work, it seems that is not right. To use low baudrate the BRG is 18. Change and try again.
If low baudrate dont work try with BRG 77 and change the register TXSTAbits.BRGH = 1, this will work with high speed baudrate.:wink:
 

Hello,
The formula that u are using the #define SPBRG not work, it seems that is not right. To use low baudrate the BRG is 18. Change and try again.
If low baudrate dont work try with BRG 77 and change the register TXSTAbits.BRGH = 1, this will work with high speed baudrate.:wink:

it seems that it received sms
but it doesn't send -_-
anyway thank you very much for your helping :) I really appreciate it
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top