Microcontroller › PIC › problem while compiling program of pic 18f4550 interfacing with gsm › Hi. I have had similar
Hi.
I have had similar problems with this project and identical errors when compiling.
I have made a couple of changes to the code to get it to compile but I am still struggling to get the project to work.
Some of the changes are:
1) where there is “RCSTA.SPEN=1” for instance I have needed to change this to “RCSTAbits.SPEN=1” this needs to be done wherever there is a register.port command
2) needed to include the correct “.h” file otherwise commands which use LATA and PORTA etc give errors
3) Also there is no “Delay_ms” function even though it is referred to in the code – not sure if maybe other versions of the compiler has this as a standard function. I have just made my own delay function
4) The checking of the Port D input pins makes no sense to me and it gives an error. So I have changed them – see the code below.
Like I said I’m still battling to get this project working and I am by no means an expert in these matters – but maybe the author can respond to some of these suggested changes.
Code below. Cheers.
#include <p18f4550.h>
#include <timers.h>
//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
//LCD Control pins
#define rs PORTBbits.RB4
#define rw PORTBbits.RB3
#define en PORTBbits.RB2
#define lcdport LATB
void tx_data(unsigned char);
unsigned char rx_data();
void lcd_ini(void);
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void gsm_cmd(unsigned char *);
void output(void);
void Delay_ms ( int delay );
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
RCSTAbits.SPEN=1; // To activate serial port (Tx and Rx pins)
TXSTAbits.TXEN=1; // Activate Transmissiom
RCSTAbits.CREN=1; // Activate Reception
PIE1bits.RCIE=1; // Enable Reception interrupt
INTCONbits.GIE=1; // Enable Global interrupt
INTCONbits.PEIE=1; // Enable Peripheral interrupt
lcd_ini();
while(1)
{
k=0;
lcdcmd(0x80);
while(starting_text[k]!=’