Skip to main content
GameDev.net gamedev.net
🔒 Locked

pic program

Started by JasonL220 Jan 3, 2007 at 12:42 PM 4 replies 750+ views
Original Post
JasonL220
JasonL220
i've been writing a program for a pic chip but i wont compile this:
void clearram(void)
{
	for( char x = 10; x >= 0; x-- )      // ERROR
	{
		for( char y = 5; y >= 0; y-- )
		{
			DispData[x][y] = 0;
		}
	}
}
i dont see what i've done wrong, the compiler doesn't say anthing useful. probably a stupid mistake. thanks
Nytegard
Nytegard
Well, fixing the obvious mistakes that GDNet made (If someone could answer why do brackets and such sometimes converted that way?), everything compiled fine, assuming DispData was declared correctly globally.

Also, you might want to replace a for loop with memset or something similar.

(It might be useful if you could actually post the errors.)
rip-off
rip-off
So, what does the compiler say?
JasonL220
JasonL220
the compiler says this:

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\MCC18\bin\mcc18.exe" -p=18F4520 "lcd.c" -fo="lcd.o" -w3 -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
MPLAB C18 v3.02 (demo)
Copyright 1999-2005 Microchip Technology Inc.
Days remaining until demo becomes feature limited: 8
D:\elec\lcd.c:166:Error: syntax error
Halting build on first failure as requested.
BUILD FAILED: Wed Jan 03 19:11:40 2007

seem rather useless to me

i would use memset but i'm not sure if the pic will support it, i just wont i t to work before i try and optimize it.

thanks
rip-off
rip-off
Maybe you need to declare all variables at the beginning of a block? Thats something you have to do in C, IIRC.

void clearram(void){        char x, y;	for( x = 10; x >= 0; x-- )	{		for( y = 5; y >= 0; y-- )		{			DispData[x][y] = 0;		}	}}
JasonL220
JasonL220
well i fix that error but it then showed a bunch more, thanks for the help didn't realise C did that differently. thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.