Home - Search - Members
Full Version: PIC/Modem Communication
PRK
Jun 6 2008, 12:43 AM
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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007