PIC C problem!

Status
Not open for further replies.

Wond3rboy

Member
Hi i have been working on getting my C cells reved up but i cant get this simple program to build.

Code:
// This is a Knight Rider Program

# pragma config LVP=OFF,WDT=OFF,OSC=INTIO2,DEBUG=ON
# include<P18f1320.h>
# include<delays.h>
void main(void)
{
	OSCCON=0x60;
	ADCON0=0X7F;
	TRISB=0;
	while(1)
	{
	near unsigned char j=0x01;
	LATB=j;
	while(j!=0x80)
		{
		 LATB=(j<<1);
		 Delay10KTCYx(100);
		}
	}
}

I have included p18f1320.h, delays.h,c018i.o,18f1320_g.lkr.But this is the error i get when i build it, this is the error i get:


I cant get whats wrong. Got the same error with the LED example code in the C18 directory and with 3V0's LED tutorial.
 
I just copied your code into an empty project file and it builds fine. I did not add a linker script as the newer version of C18 doesn't require one.

Mike.
 
Mike is correct.

Did you find the problem ?

3v0
 
Hi Mike and 3v0,

Thanks for your replies.I found the problem. the 'include' and 'library' file paths were not set in the 'Build options'. I set the locations and it works fine now.I guess the problem was with the drive i installed it(installed both MPLab and C18 in E:\),but i reckon it should have been set by default.
 
Last edited:
But one thing that i find strange is that i have to set the paths for both of them in each project.Also i have one question, whats wrong with this statement:

LATB=(i>>1)

I had to substitute this with

LATB=LATB>>1

I mean it should work, shouldnt it??
 
Use the project wizard to create your projects.

The two statements do different things.
Code:
LATB=(i>>1);
shifts i right 1 bit and assigns the value of i to LATB.
if i were 0x04 shifting it right would make i 2
and that value would be assigned to LATB.

Code:
LATB=LATB>>1;
This shifts LATB one right and assigns back to LATB. You could write it as

Code:
LATB>>1;
because after the shift LATB already contains the new value.
 
Thanks.
I always use the project wizrd for creating MPLAB projects(got it from your video tutorial).I guess then its some installation problem will check it out and see if i fix it.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…