Microcontroller › PIC › This Code is not working on MPLAB can anyone help me
- This topic has 0 replies, 1 voice, and was last updated 8 years, 9 months ago by AHMAD JAVED.
-
AuthorPosts
-
November 24, 2015 at 6:02 pm #4128AHMAD JAVEDParticipant
//Program to interface GSM Modem with PIC18F4550 Microcontroller
//This code takes four choices as four inputs
//Choice 1 : Test the simple AT Command.
//Choice 2 : Find out the IMEI number of the GSM Modem.
//Choice 3 : Connect a call to a GSM mobile number.
//Choice 4 : Send a text message to a mobile number.#define FREQ 12000000
#define baud 9600
#define spbrg_value (((FREQ/64)/baud)-1)
#define rs LATA.F0
#define rw LATA.F1
#define en LATA.F2
#define lcdport LATBvoid tx_data(unsigned char);
unsigned char rx_data();
void lcd_ini();
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void gsm_cmd(unsigned char *);
void output(void);unsigned char value=0;
int i=0,j,k,temp,flag,choice;
unsigned char *starting_text=”Enter choice=”;
unsigned char *dial_text=”Dialing…”;
unsigned char *at_cmd=”AT”;
unsigned char *imei_cmd=”AT+GSN”;
unsigned char *call_cmd=”ATD9xxxxxxxxx;”; // Provide a 10-Digit Mobile Number
unsigned char *sms_format=”AT+CMGF=1″;
unsigned char *sms_write=”AT+CMGS=”xxxxxxxxxx””; // 10-Digit Mobile Number
unsigned char *sms=”Hello”;
unsigned char *sms_report=”SMS Sent…”;
unsigned char sms_terminate=0x1A;
unsigned char enter=0x0D;
unsigned char *data;void main()
{
TRISB=0; // Set Port B as output port
LATB=0;
TRISA=0;
LATA=0;
TRISD=0xFF;
LATD=0;
SPBRG=spbrg_value; // Fill SPBRG register to set the baud rate
RCSTA.SPEN=1; // To activate serial port (Tx and Rx pins)
TXSTA.TXEN=1; // Activate Transmissiom
RCSTA.CREN=1; // Activate Reception
PIE1.RCIE=1; // Enable Reception interrupt
INTCON.GIE=1; // Enable Global interrupt
INTCON.PEIE=1; // Enable Peripheral interruptlcd_ini();
while(1)
{
k=0;
lcdcmd(0x80);
while(starting_text[k]!=’