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.

Need Help with program

Status
Not open for further replies.

flyingfrancisco

Newbie level 6
Joined
Mar 22, 2011
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Green Valley, Ontario
Activity points
1,348
Hello everyone
I am both new to this site and new to Pic programming.Can someone tell me what is wrong with this. It will not build in MikroC and I get the first error at line 10 " Syntax error Expected ")' but found "="


unsigned long value; // store the value of channel0
unsigned char d1,d2,d3,d4,*text; //d1,d2,d3,d4, are to convert the input data

#define printV lcd_chr(2,11,d1+48); lcd_chr_cp(d2+48);\
lcd_chr_cp(*.*); lcd_chr_cp(d3+48);\
lcd_chr_cp(d4+48); lcd_out_cp("V");

void main()
(
adcon1=0b10000010; // analog channels activated
trisa=0xff; // PortA configured as input
lcd_config(&portb,1,3,2,7,6,5,4,);
lcd_cmd(LCD_CURSOR_OFF);
lcd_cmd(LCD_CLEAR);
text=("PACO's Project");
lcd_out(1,2,text);
text=("voltage:");
lcd_out(2,1,text);
for(;;)
(
value=adc_read(0);
value=value*5000/1023:
d1=value/1000:
d2=(value%1000)/100;
d3=((value%1000)%100)/10;
d4=((value%1000)%100)%10;
printV;
delay_ms(20);
)
)
 
Last edited by a moderator:

this is same as yours bu for another function


//Mahmoud Hassan
//Analog Temp. read
// Lcd pinout settings
sbit LCD_RS at Rd4_bit;
sbit LCD_EN at Rd5_bit;
sbit LCD_D7 at Rd3_bit;
sbit LCD_D6 at Rd2_bit;
sbit LCD_D5 at Rd1_bit;
sbit LCD_D4 at Rd0_bit;

// Pin direction
sbit LCD_RS_Direction at TRISd4_bit;
sbit LCD_EN_Direction at TRISd5_bit;
sbit LCD_D7_Direction at TRISd3_bit;
sbit LCD_D6_Direction at TRISd2_bit;
sbit LCD_D5_Direction at TRISd1_bit;
sbit LCD_D4_Direction at TRISd0_bit;


unsigned int y,rem;
unsigned char thousnads,hundreds,tens ,ones;

void main()
{
lcd_init();
lcd_out(1,1,"TEMP:");
lcd_chr(1,11,0b11011111);
lcd_out(1,12,"C");
ADCON1=0b00001110;

for(;;)
{
y=(long)adc_read(0)*500/1023;
thousnads=y/1000;
rem=y%1000;
hundreds = rem/100;
rem = rem%100;
tens =rem/10;
ones = rem%10;

lcd_chr(1,6,thousnads+0x30);
lcd_chr_cp(hundreds+0x30);

lcd_chr_cp(tens+0x30);
lcd_chr_cp(ones+0x30);







}

}
 

I think you need brackets{} around your functions, instead of parentheses().

void main()
{
//code goes here
}

Also, your for(;;) loop looks suspiciously incomplete. General C-like syntax is:
for (<variable>; <conditional>; <step> )
example
for (i = 0; i < 100; i = i + 1)

Perhaps for an infinite loop you'd use while(1) or while(TRUE)? Maybe for(;;) does that; not sure.
 

Thank you both for your quick replies Now it builds until line 27 and then I get error code" Indentifier expected but " found. Also the next errors are ..... Pointer required.....internal error........and invalid expression.
 

This is the part where, as a novice programmer, you learn the joy and pain of debugging your own code... you'll have to do this a lot, so start your practice now.

Hint:
Start by commenting out the present line (printV;) and copy/pasting the code from the #define printV in it's place. Break the six commands up onto unique lines, then let the debugger tell you which line it's having a problem with, and figure out what's wrong with that line (syntax, usage, value supplied, number of parameters, etc).
 

This is the part where, as a novice programmer, you learn the joy and pain of debugging your own code... you'll have to do this a lot, so start your practice now.

Hint:
Start by commenting out the present line (printV;) and copy/pasting the code from the #define printV in it's place. Break the six commands up onto unique lines, then let the debugger tell you which line it's having a problem with, and figure out what's wrong with that line (syntax, usage, value supplied, number of parameters, etc).

Thank you very much for your advice. By commenting out lines I was finally able to fix my program. Thank you all for your kind advice.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top