Jan De
Newbie level 4
- Joined
- May 7, 2014
- Messages
- 7
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 46
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.
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.;-)
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.
// 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:
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?
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:
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?