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.

gsm interfacing with microcontroller

Status
Not open for further replies.

djougue

Newbie level 5
Joined
Oct 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,348
good morning,
please i have a problem when trying to interface sim900 by a microcontroller(pic24F256GB106) in a given board. Indeed, SIM900 and pic24F256GB106 are related as follows:
RF1 pin with TX
RF0 pin with RX
since that the pin corresponding to RF1 is not RPORT, how can i define RF1 as the transmission pin of UART2 module? such that i will be able to send AT command to sim900 by this port.

I only know to define TX,RX pin in UART2 using RPOR Or RPIN as follow:
RPINR19bits.U2RXR = 24; // Assign RD1/RP24 to U2RX (input)
RPOR11bits.RP22R = 5; // Assign RD3/RP22 to U2TX (output)

in other word how can i use other pins as TX and RX pin in UART2 module?
 

GSM Man

Banned
Joined
Apr 15, 2009
Messages
671
Helped
168
Reputation
338
Reaction score
94
Trophy points
1,308
Location
New Jersey, USA
Activity points
0
Yon can't use RF0 or RF1 as a UART pin becuase neither of them is a Peripheral Pin. From the Microchip Datasheet:
The Peripheral Pin Select feature is used with a range of up to 44 pins, depending on the particular device and its pin count. Pins that support the Peripheral Pin
Select feature include the designation, “RPn” or “RPIn”, in their full pin designation, where “n” is the remappable pin number. “RP” is used to designate pins that support
both remappable input and output functions, while “RPI” indicates pins that support remappable input functions only.
 

djougue

Newbie level 5
Joined
Oct 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,348
tank you,
since that the board is designed like this please how can i send that through RF1 pin instead of using TX pin in uart?
 

GSM Man

Banned
Joined
Apr 15, 2009
Messages
671
Helped
168
Reputation
338
Reaction score
94
Trophy points
1,308
Location
New Jersey, USA
Activity points
0
About the only choice you have is to "Bit Bang" the data. There are plenty of examples on the web of how to do that.
 

djougue

Newbie level 5
Joined
Oct 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,348
About the only choice you have is to "Bit Bang" the data. There are plenty of examples on the web of how to do that.
take you for your answer. After performing some research on the web i get some examples only for old pic (pic12f) i decide to write my own code for pic24FJ256GB106 but it doesn't work. what factors i have not taken in consideration or what wrong with this code?

"bit banging" code that i have written for "pic24F"

CLOSEST_UBRG_VALUE=51 //9600 baute rate

void send_serial_byte(unsigned char data)
{
unsigned char i;

i=8; // 8 data bits to send

UARTTX_TRIS = 1; // make start bit


DelayMs(CLOSEST_UBRG_VALUE);

while(i!=0) // send 8 serial bits, LSB first
{
if (data & 0x80)
UARTTX_TRIS = 1;
else
UARTTX_TRIS = 0;
data = (data << 1); // rotate right to get next bit
i--;

DelayMs(CLOSEST_UBRG_VALUE);
}
UARTTX_TRIS = 0;
DelayMs(CLOSEST_UBRG_VALUE);
}


void UART2PrintString( char *str )
{
unsigned char c;

while( (c = *str++) )
send_serial_byte(c);
}
 

BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
Code:
while(1)
{
     TRISD=0x00;
      TRISC=0xC0;
}
 

djougue

Newbie level 5
Joined
Oct 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,348
Code:
while(1)
{
     TRISD=0x00;
      TRISC=0xC0;
}

this is the main code that i have written

OSCCON = 0x3302; // Enable secondary oscillator
CLKDIV = 0x0000; // Set PLL prescaler (1:1)


UARTInit();

TRISFbits.TRISF1=0; //configure RF1 input (RX)
TRISFbits.TRISF0=1; //configure RF0 output (TX)
//printf("AT\r\n");
UART2PrintString("AT\r\n");
DelayMs(2000);
UART2PrintString("ATE0\r\n");
DelayMs(2000);
UART2PrintString("AT+CMGS=\"+77773779\"\r\n");
DelayMs(2000);
UART2PrintString("TEST DATA FROM RhydoLABZ-COCHIN");
UART2PrintString(0x1a);
DelayMs(2000);
while(1);
 

GSM Man

Banned
Joined
Apr 15, 2009
Messages
671
Helped
168
Reputation
338
Reaction score
94
Trophy points
1,308
Location
New Jersey, USA
Activity points
0
Add the following defines to your project:
Code:
#define UARTTX_TRIS	TRISFbits.TRISF0
#define UARTTX_BIT	LATFbits.LATF0

Then add this code to your initialization function:
Code:
UARTTX_TRIS = 0; 		// Make TX line an Output
UARTTX_BIT = 1;			// Set TX line high

Your serial transmit function should be something like this:
Code:
void send_serial_byte(unsigned char data)
{
	unsigned char i;
	
	UARTTX_TRIS = 0; 				// Drive Line low for 1-bit time for start bit
	DelayMs(CLOSEST_UBRG_VALUE);
	
	for (i=0; i<8; i++) 				// Send 8 serial bits, LSB first
	{
		if (data & 0x01)			// Output bit....
			UARTTX_BIT = 1;
		else			
			UARTTX_BIT = 0;
		DelayMs(CLOSEST_UBRG_VALUE);		// then delay one bit time
		data>>= 1; 				// Shift Right to get next bit
	}
	
	UARTTX_BIT = 1;					// Output 1 stop bit...
	DelayMs(CLOSEST_UBRG_VALUE);			// then delay one bit time
}
 

djougue

Newbie level 5
Joined
Oct 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,348
take you for this code. Now what do you thing about the gsm modem code (main of project)

- - - Updated - - -

take you for this code. Now what do you thing about the gsm modem code (main of project)
 

GSM Man

Banned
Joined
Apr 15, 2009
Messages
671
Helped
168
Reputation
338
Reaction score
94
Trophy points
1,308
Location
New Jersey, USA
Activity points
0
I HIGHLY recommend that you don't depend on delays but read the response send by the module and act accordingly. The time it takes for the module to respond varies greatly, and while your delays may work for now, they may not be long enough to cover the "fringe" cases; and it can take a lot of effort to track down those types of problems.

To send the an SMS message perform the following (This is a FAQ from www.GsmMadeEasy.com):
Code:
Send the following commands to the module - Each line must be terminated with a 'Carriage Return':
	AT+CMGF=1   	- Set the module into Text mode
	AT+CSCS='GSM'   - Set the character mode to GSM
	AT+CSCA='###'   - Set the SMS message center number, ### = number for your service provider
	AT+CMGS='###'   - Start sending SMS, ### = phone number to send message to
			 - The module will return'>'to indicate it is ready for the text
	This is a Test   - Send the text, followed by [B]ctrl-Z[/B] and Carriage Return

This F
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top