Discussion in "Embedded GSM Development" started by    PRK    Jun 6, 2008.
Fri Jun 06 2008, 01:13 pm
#1
Hi, I'm a student working on a GSM modem that receives SMS messages through AT commands from a PIC microcontroller. I have been able to get the modem to communicate with my PC and I have also been able to have the PIC communicate with my PC. However, I am to have the two communicate with each other. My code compiles and executes however no message is sent. My code is below:

#include <p30fxxxx.h>
#include "system.h"
#include "uart.h"


//Declaration to Link External Functions & Variables:
extern Delay5ms (int);

//Functions and Variables with Global Scope:
void INTx_IO_Init(void);
unsigned char *LCDCharPtr;


void InitUART1(void)
{
unsigned int U1MODEvalue;
unsigned int U1STAvalue;
unsigned int baudvalue = 23; // ((FCY[MIPS]/16)/BAUDRATE) -1 -> 8 = 230400 baud
// 17 = 115200 baud

CloseUART1();
IFS0bits.U1RXIF=0;
IFS0bits.U1TXIF=0;

ConfigIntUART1(UART_RX_INT_DIS & UART_RX_INT_PR6 & UART_TX_INT_DIS &
UART_TX_INT_PR2);
U1MODEvalue = UART_EN & UART_IDLE_CON & UART_DIS_WAKE & UART_DIS_LOOPBACK &
UART_EN_ABAUD & UART_NO_PAR_8BIT & UART_1STOPBIT;
U1STAvalue = UART_INT_TX_BUF_EMPTY & UART_TX_PIN_NORMAL & UART_TX_ENABLE
&UART_INT_RX_3_4_FUL & UART_ADR_DETECT_DIS & UART_RX_OVERRUN_CLEAR ;
OpenUART1(U1MODEvalue,U1STAvalue,baudvalue);
}


int main(void)
{

InitUART1();
INTx_IO_Init();
while(1)
{

putsUART1((unsigned int*)"AT\r");
while(BusyUART1());
Delay5ms(1000);

putsUART1((unsigned int*)"AT+CSQ\r");
while(BusyUART1());
Delay5ms(1000);


putsUART1((unsigned int*)"AT+CMGF=1\r");
while(BusyUART1());
Delay5ms(1000);

putsUART1((unsigned int*)"AT+CMGS = 3014556841\r");
while(BusyUART1());
Delay5ms(1000);

putsUART1((unsigned int*)"Hello Pooya");
while(BusyUART1());
Delay5ms(1000);
WriteUART1(0x1A);
while(BusyUART1());
WriteUART1('\r');
while(BusyUART1());
Delay5ms(1000);



}
return 0;
}

Thank you for your time.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm