Jump to content
Sign in to follow this  
16F876

Program Gives Silly Error And Does Not Complile

Recommended Posts

This following program does not compile with Sourceboost C2C Plus 5.3. It gives the error : Error: General error in function definition on line 72 which is exacltly the same as the code on line 78 namely, clear_bit (portc,RS) ;

 

I have tried, output_low_port_c (RS); and clear_bit (portc,5); with no success. In general the code may be wrong for what I am trying to do, but it is the syntax that seems to be the problem. I have tried using hex instead of my prefered binary in some statements, but with no success.

 

Please help me get this going.

 

 

/* Trying to get to grips with this */

 

#include <system.h>

#define ebit 00010000b /*bit4*/

#define RS 00100000b /*bit5*/

#define rsmask 00110000b

#define lcdstart_delay 1 /* 2500 */

#define stndwrite_delay 1 /* 100 */

#define clrlcd_delay 1 /*2000 */

 

unsigned int place, celsius, ones, tens, hund, thou, tenk, temp0, temp1;

unsigned int temp2, temp3, temp4, progno, ahi, amd, alo, bhi, bmd, blo, a1hi;

unsigned int a1lo, b1hi, b1lo, multi0, multi1, h0, h1, h2;

unsigned int sign, rscom, aargb2, aargb1, aargb0, factor, divide2;

unsigned int divide3, product, product1, product2, product3, product4, product5;

unsigned int zoom0, zoom1, loopcount, bargb0, bargb1, multipland, multipland1;

unsigned int multipland2, multi2, c1hi, c1lo, d1lhi, d1lo, cntr1, x, y;

unsigned int Zero, answer, Ba, avg ;

unsigned char temp, disp;

 

const unsigned char lcd_init [5] =

{

/* Display off */

0x08,

/* Display clear */

0x01,

/* Entry mode set */

0x06,

/* Display on/underline off-Blink off */

0x0C,

/* Function set big display */

0x2C

 

};

const unsigned char message [5] =

{

'H', 'E', 'L', 'L', 'O'

} ;

 

void E (void)

{ portc=portc^0x08;

stndwrite_delay();

portc=portc^0xEF;

}

void IN (void)

{ temp=disp; /* move display to temporary */

asm swapf(temp);

temp= temp&0x0f;

portc=temp;

portc=portc^11100000b ;

E();

temp=disp;

temp=temp&0x0F;

portc =portc^0xE0;

E();

}

 

void lcdstart (void)

{

 

clear_bit (portc,ebit); /* Clear Ebit */

output_high_port_c (0x01); /* Function set--4 bits */

E(); /* call E */

stndwrite_delay();

 

unsigned char i ;

for ( i=0 ; i<5 ;i++ )

{

disp=lcd_init;

IN();

stndwrite_delay();

}

clear_bit (portc,RS) ; /* !!!!! Line 72 !!!!!! */

}

 

 

void display (void)

{

clear_bit (portc,RS); /* !!!!! Line 78 !!!!!!!!*/

disp=0xC0; /* Display address 40 */

IN();

set_bit (portc,RS);

 

unsigned char j ;

for ( j=0 ; j<5 ;j++ )

{

disp=message[j];

IN();

stndwrite_delay();

}

output_low_port_c(RS);

}

 

 

 

 

void setup (void)

{

 

/* Setup*/

trisa=0x17 ; /* make all port a except TA4 input*/

trisb=0x1F ;

clear_bit (option_reg,RBPU); /* portb pullups enabled - normally set */

clear_bit (pie1,PSPIE); /* Disables AD convert interupt */

trisc=0x80; /* make just RC7 input for RS232 */

/*SetBaud*/

clear_bit (intcon, gie); /*disables global interupt*/

clear_bit (intcon, t0ie); /* disables peripheral interupts */

clear_bit (intcon, inte) ; /* disables all external interupts*/

clear_bit (intcon, rbie); /* disables all RB port interupts */

portc=0; /*clear portc*/

spbrg=0x19 ;

txsta=0x04 ;

clear_bit (pie1,txie) ; /* clears interupt bit */

rcsta=0x90; /*enables serial port, SPEN bit set-enables reception */

set_bit (txsta, txen); /* enables transmission */

}

 

void main (void)

 

{ setup () ;

lcdstart ();

display();

 

}

Share this post


Link to post
Share on other sites

Which processor is the target device ?

 

Looks like you use of macros is messing things up, try changing

#define stndwrite_delay 1 /* 100 */

 

to

 

#define stndwrite_delay() delay_ms( 1 ); /* 100 */

 

This gets rid of the error to which you refer.

But then I cant complete the build - maybe because I have the wrong target selected.

 

Regards

Dave

Share this post


Link to post
Share on other sites

The device is the PIC16F876.

 

You advice worked thank you very very much. I was working on this problem for a long time so thank you very very much.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...