• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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:

----------------------------------------------------------------------
Debug build of project `E:\PIC Tutorials\Assembly\Projects MPLAB\CPRograms\NightRider.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Sat Jul 18 10:42:19 2009
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "E:\PIC Tutorials\Assembly\Projects MPLAB\CPRograms\knightrider.o".
Clean: Deleted file "E:\PIC Tutorials\Assembly\Projects MPLAB\CPRograms\NightRider.mcs".
Clean: Done.
Executing: "E:\MCC18\bin\mcc18.exe" -p=18F1320 "E:\PIC Tutorials\Assembly\My made\CPrograms\knightrider.c" -fo="knightrider.o" -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "E:\MCC18\bin\mplink.exe" "..\..\..\..\MCC18\bin\LKR\18f1320_g.lkr" "knightrider.o" "E:\MCC18\lib\c018i.o" /u_CRUNTIME /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"NightRider.cof" /M"NightRider.map" /W
MPLINK 4.32, Linker
Link step failed.
----------------------------------------------------------------------
Debug build of project `E:\PIC Tutorials\Assembly\Projects MPLAB\CPRograms\NightRider.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Sat Jul 18 10:42:24 2009
----------------------------------------------------------------------
BUILD FAILED
I cant get whats wrong. Got the same error with the LED example code in the C18 directory and with 3V0's LED tutorial.
 

Pommie

Well-Known Member
Most Helpful Member
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.
 

Wond3rboy

Member
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:

Wond3rboy

Member
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??
 

3v0

Coop Build Coordinator
Forum Supporter
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.
 

Wond3rboy

Member
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.

Latest threads

EE World Online Articles

Loading
Top