Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem with hi-tech c compiler

Status
Not open for further replies.

samnang39

Full Member level 2
Joined
Oct 26, 2006
Messages
130
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Cambodia
Activity points
2,246
My code is
#include <htc.h>
#define _XTAL_FREQ 20000000
#define BAUD 9600

void pic_init(void);
void uart_init(void);

void uart_transmit(char data);
void uart_string(const char *s);

char gsm[90],rec[]={"+CMTI"};
unsigned int counter,z;

static void interrupt isr(void)
{
if(RCIF==1)
{
counter=0;
gsm[z]=RCREG;
if(z<88) z++;
}
/*
if(TMR0IF==1) //Overflow interrupt flag
{
TMR0IF=0;
if(counter<20000) counter++;
if(counter==5000) z=0;
} //*/
}

main()
{
int i;
pic_init(); //initialize PIC
uart_init(); //initialize UART

for(i=0;i<=89;i++) gsm=0x20;

uart_string("AT+CMGS="); //Send message
uart_transmit(0x22); //"
uart_string("+601xxxxxxxx"); //Phone no
uart_transmit(0x22); //"
uart_transmit(0x0D); //Enter
uart_string("Hi, I'm PIC16F877A"); //Text message
uart_transmit(0x0D); //Enter
uart_string("Reply, if you receive this message");
uart_transmit(0x1A); //Ctrl+Z

}

void pic_init(void)
{
TRISA= 0b00000000;
TRISB= 0b00000000;
TRISC= 0b10000000;
//OPTION= 0b00000000;
ADCON1= 0b00000110;
INTCON= 0b11100000;
PIE1= 0b00100000; //Enable RX interrupt
PORTA= 0b00000000;
PORTB= 0b00000000;
PORTC= 0b00000000;
}

void uart_init(void)
{
TXSTA=0b10100000;
RCSTA=0b10010000;
SPBRG=(int)(_XTAL_FREQ/(64.0*BAUD)-1);
}

void uart_transmit(char data)
{
while(TXIF==0) continue;
TXREG=data;
}

void uart_string(const char *s)
{
// while(*s)
// uart_transmit(*s++);
//*
while((*s)!='\0')
{
//Wait for TXREG Buffer to become available
while(!TXIF);

//Write data
TXREG=(*s);

//Next goto char
s++;
}
//*/
}

but after i bill by use MPLAB the output is
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Users\Huot Samnang\Documents\Project4Sell\GSMmodule\SMSExcavator.p1".
Clean: Deleted file "C:\Users\Huot Samnang\Documents\Project4Sell\GSMmodule\SMS4Excavator.mcs".
Clean: Done.
Build C:\Users\Huot Samnang\Documents\Project4Sell\GSMmodule\SMS4Excavator for device 18F2550
Using driver C:\Program Files (x86)\HI-TECH Software\PICC-18\PRO\9.64\bin\picc18.exe

Executing: "C:\Program Files (x86)\HI-TECH Software\PICC-18\PRO\9.64\bin\picc18.exe" --pass1 "C:\Users\Huot Samnang\Documents\Project4Sell\GSMmodule\SMSExcavator.c" -q --chip=18F2550 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [192] C:\Users\Huot Samnang\Documents\Project4Sell\GSMmodule\SMSExcavator.c; 16.4 undefined identifier "RCIF"
Error [192] C:\Users\Huot Samnang\Documents\Project4Sell\GSMmodule\SMSExcavator.c; 74.7 undefined identifier "TXIF"
Error [192] C:\Users\Huot Samnang\Documents\Project4Sell\GSMmodule\SMSExcavator.c; 86.8 undefined identifier "TXIF"

********** Build failed! **********
i don't know why the compiler can not know "RCIF" and......
please help me
Thanks in advance
 

Hi;
I never tried to prgram 18F series with picc.
But did you consider to include specific 18F2550 header?
Good luck
 

yes i used to include already but still problem
 

Please have a check the header file content. Maybe these bits are not defined in the header.
ie my 16f877 header has this kind of definition for TXIF;
Code:
static volatile bit	TXIF	@ (unsigned)&PIR1*8+4;

If this kind of defintion is not available, you should read whole register and then mask for necessary bits.
Hope helps
 
Thanks Emresel what is
extern volatile near unsigned char PIR1;
extern volatile near struct {
unsigned TMR1IF:1;
unsigned TMR2IF:1;
unsigned CCP1IF:1;
unsigned SSPIF:1;
unsigned TXIF:1;
unsigned RCIF:1;
unsigned ADIF:1;
} PIR1bits;
mean could you please explain me
 

TXIF and RCIF are defined as variables, one bit wide, in the PIR1 bitfield structure.
The structure is named PIR1bits.

You access the bits in the same way you access variables in a structure.

PIR1bits.RCIF = 1;

Look up 'bitfield' for more information.
 

Thank for your reply yes i understand about this already but i want to know the " extern volatile near " mean?
 

Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top