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 sim 900 to pic32 controllers

Status
Not open for further replies.

shruthi b

Newbie level 4
Joined
May 26, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,323
Hi every one,

This is my first post in this forum, i am trying to interface GSM sim 900 simcom module with pic32mx360f512l microcontroller.when i connect gsm/gprs module directly to PC using hyper terminal it is working properly and i can able to attend cal and can also do calling.but when i interface it with pic controller it wont give any response.i am sending command "AT"followed by "0x0D " carriage return . please can any one help me .

Thanks in advance.
shruthi
 

Hi,

Can you psot the schematics and the code. So that one could know whats going on... I have interfaced SIM-900 with dsPIC33F micro and its works fine. The commands to the modem are as follow...

SendSerialStringU2("AT\r");
getresponse();
SendSerialStringU2("ATE0\r");
getresponse();


Enjoy!
 
Post your code and hardware interfacing circuit.
IF you feel everything is OK then try to increase the delay after sending AT\r for minimum of 800ms.then read the recieved data.

- - - Updated - - -

Post your code and hardware interfacing circuit.
IF you feel everything is OK then try to increase the delay after sending AT\r for minimum of 800ms.then read the recieved data.
 
hi

thank you for your reply. I am connecting pic32mx360f512l UART2 RX pin to GPRS Tx pin and UART2 TX to GPRS RX pin and gnd pis. i am not getting how to collect response from GPRS and how to display that. I am attached my code and schematics. My code for uart interrupt .it echo the data which write in hyper terminal . Can u please send me your code to b.shruthiraj@gmail.com.

thanks in advance,
shruthi b
 

Attachments

  • gprs.png
    gprs.png
    33.6 KB · Views: 134
  • uartint.txt
    7.1 KB · Views: 83

Without using Serial interrupt to receive data you will not be able to receive data properly. Whenever there is a serial receive interrupt you have to store data in an array and increment the array index and then finally after all data is received then terminate the array with null character if the data is a string else no need to terminate the array.

PIC32MX360F512L MPLAB C32 C 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
unsigned char greceiveddata[45];
unsigned int i = 0;
unsigned char atcmd1[] = "AT\r";
unsigned char atcmd2[] = "ATE0\r";
 
// UART 2 interrupt handler
// it is set at priority level 2
void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)
{
    // Is this an RX interrupt?
    if(U2RXIF)
    {
        if(OERR){
            OERR = 0;
        }
 
        // Clear the RX interrupt Flag
            U2RXIF = 0;
 
        greceiveddata[i++] = U2RXREG;
 
        greceiveddata[i] = '\0';
            
        // Echo what we just received.
        PutCharacter(greceiveddata[i-1]);       
 
        // Toggle LED to indicate UART activity
        mPORTAToggleBits(BIT_7);
 
    }
    
}
 
 
int main(void)
{
    lcd_init();
    lcd_cmd(0X1);//clear disp
    delay(1000);
    lcd_cmd(0X38);//8 bit 2 line mode
    delay(1000);
    lcd_cmd(0X0C);// cursor blink
    delay(1000);
    lcd_cmd(0X06);//move right
    delay(1000);
    lcd_cmd(0X80);//first line first position
    delay(1000);
    
    greceiveddata[0] = '\0';
    
    #if defined (__32MX220F032D__) || defined (__32MX250F128D__)
    U2RXRbits.U2RXR = 1; //SET RX to RPB5
    RPB0Rbits.RPB0R = 2; //SET RPB0R to TX
    #endif
 
    // Configure the device for maximum performance but do not change the PBDIV
    // Given the options, this function will change the flash wait states, RAM
    // wait state and enable prefetch cache but will not change the PBDIV.
    // The PBDIV value is already set via the pragma FPBDIV option above..
    SYSTEMConfig(GetSystemClock(), SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
 
    mPORTAClearBits(BIT_7);         // Turn off RA7 on startup.
    mPORTASetPinsDigitalOut(BIT_7); // Make RA7 as output.
 
 
    // Explorer-16 uses UART2 to connect to the PC.
    // This initialization assumes 36MHz Fpb clock. If it changes,
    // you will have to modify baud rate initializer.
        UARTConfigure(UART2, UART_ENABLE_PINS_TX_RX_ONLY);
        UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_NOT_FULL |              
 
    UART_INTERRUPT_ON_RX_NOT_EMPTY);
        UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE |        
 
                UART_STOP_BITS_1);
        UARTSetDataRate(UART2, GetPeripheralClock(), DESIRED_BAUDRATE);
        UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX));
 
    // Configure UART2 RX Interrupt
    INTEnable(INT_SOURCE_UART_RX(UART2), INT_ENABLED);
        INTSetVectorPriority(INT_VECTOR_UART(UART2), INT_PRIORITY_LEVEL_2);
        INTSetVectorSubPriority(INT_VECTOR_UART(UART2), INT_SUB_PRIORITY_LEVEL_0);
 
        // configure for multi-vectored mode
        INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
 
        // enable interrupts
        INTEnableInterrupts();
 
 
    WriteString("*** UART Interrupt-driven Application Example ***\r\n");
    WriteString("*** Type some characters and observe echo and RA7 LED toggle ***   
 
        \r\n");
 
 
    // Let interrupt handler do the work
 
    while (1);
        {
            SendData2UART(atcmd1);
        while(greceiveddata[0] != '\0')
            lcd_cmd(0X80);
        lcd(greceiveddata);
        greceiveddata[0] != '\0';
        }
 
    return 0;
}
 
// helper functions
void WriteString(const char greceiveddata[])
{
    unsigned int j = 0;
 
    while(greceiveddata[j++] != '\0')
    {
        while(!UARTTransmitterIsReady(UART2));
        UARTSendDataByte(UART2, greceiveddata[j]);
        while(!UARTTransmissionHasCompleted(UART2));
    }
}
 
void PutCharacter(const char character)
{
        while(!UARTTransmitterIsReady(UART2));
        UARTSendDataByte(UART2, character);
        while(!UARTTransmissionHasCompleted(UART2));
}
 
void SendData2UART(unsigned char data_[45]){
    unsigned int j = 0;
 
    while(data_[j++] != '\0')PutCharacter(data_[j]);
}



**broken link removed**
 
Last edited:

Hi,

As far as the connections are concerned they are correct; however I have googled some good tutorial for PIC32 UART.

HTML:
http://umassamherstm5.org/tech-tutorials/pic32-tutorials/pic32mx220-tutorials/uart-to-serial-terminal

HTML:
http://www.eedesignlabs.com/pic32-tutorial-4-uart-communication/

HTML:
https://code.google.com/p/pic32-examples/source/browse/trunk/tedious/library/uart.c?r=23

Enjoy!
 

If you are interfacing with pc than surely through max232. N in schematic you are directly connected to pic and you can't do that use an other max232 on the pic side or remove max232 on gsm/gprs side and program pic on 3.7V
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top